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

Check for dirty fields in modal dialog #140

Open AkinOlawale opened 5 years ago

AkinOlawale commented 5 years ago

How can i enable the are you sure check in a modal dialog? Currently what happens is that it only displays the are you sure check when i close the dialog and try to either re-load or switch pages.

AkinOlawale commented 5 years ago

I found a way around this.

  1. I turned on the silent mode using $('#form').areYouSure({'silent': true});
  2. Then i used this hasClass('dirty') to check if the form is dirty
  3. Then i added a fancy box to alert the user before proceeding to close the modal dialog