jquery.AreYouSure icon indicating copy to clipboard operation
jquery.AreYouSure copied to clipboard

How to disable plugin on form submit?

Open tanraya opened this issue 8 years ago • 2 comments

Hello! I want to see the warning message only when I close the window or leave page, but not on the form submit.

So how can I disable the warning message on form submit?

tanraya avatar Apr 09 '16 12:04 tanraya

There is already a code for this purpose inside the plugin. But if you use ajax for submit, you need to remove dirty class from the form(s) or you need to unbind beforeunload handler.

$form.submit(function() {
    $form.removeClass(settings.dirtyClass);
});

hasangursoy avatar Jun 01 '16 14:06 hasangursoy

This issue is actually because you are replacing the form element in your code, jquery are you sure still thinks its tracking the form but the assigned events are lost.

This bug seems to crop up after validation errors or such. You must add code similar to the following to fix this issue.

$(document).ajaxComplete(function(){

  $("form").submit(function(){
    $(this).removeClass('dirty');
  });

});

We should find a way to integrate this code into the library so users dont have to do this themselves.

westonganger avatar Apr 08 '19 16:04 westonganger