Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable plugin on form submit? #109

Open
tanraya opened this issue Apr 9, 2016 · 2 comments
Open

How to disable plugin on form submit? #109

tanraya opened this issue Apr 9, 2016 · 2 comments

Comments

@tanraya
Copy link

tanraya commented Apr 9, 2016

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?

@hasangursoy
Copy link

hasangursoy commented Jun 1, 2016

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);
});

@westonganger
Copy link

westonganger commented Apr 8, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants