codedance / jquery.AreYouSure

A light-weight jQuery "dirty forms" Plugin - it monitors html forms and alerts users to unsaved changes if they attempt to close the browser or navigate away from the page. (Are you sure?)
507 stars 145 forks source link

Does it work with iframe? #92

Open Venkat-GP opened 8 years ago

Venkat-GP commented 8 years ago

I am trying to implement this in my current project.

We have a HTML page and it contains a iframe, in which a form is defined.

So if changes happen in form(which is in iframe) and try to navigate to other page without saving it is not working for me.

Please let me know if there is any workaround to accomplish this with iframes in HTML page.

Thanks

Jezza commented 8 years ago

Yeah, we have this issue as well. We have an embedded iframe within a form, for various reasons, and we can't select it with the fieldSelector. I wanted to ask before I went it and just did a quick edit to add a callback option for additional code to run when retrieving the fields.

Jezza commented 8 years ago

Yeah, so after a bit of mucking around, I just resorted to altering the file to allow a callback so you can add your own fields directly. This allowed me to search for the iframe, once loaded, and track it with the rest.

Sazira commented 8 years ago

Hey @Jezza can you please tell me what changes you made to the file? I have an iframe inside a form and AreYouSure isn't working for that iframe

Jezza commented 8 years ago

I legally can't post the code, but I can tell you tell I simply added a parameter to the initial call that is simply a function. This function is fired when any fields are selected with the field-selector, and I pass the selections back into the callback function, and add to it. I fire the initial form check on DOM load, attach an event to the iframe, and simply research with the fancy new callback, manually searching for the iframe.