Skip to content

Commit

Permalink
Prevent beforeunload feature from double submitting when clicking submit
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Reishus committed Oct 4, 2011
1 parent d129264 commit 37ba311
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions jquery.autosaveform.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@ $.fn.ASF_debug = true; # turn on debug messages in console
} }
return false; return false;
}); });

// If using unload feature, deregister a form from autosaving upon unload
if ($.fn.ASF_beforeunload) {
$(form).submit(function() {
var ASF_forms = $(window).data("ASF_forms");
ASF_forms = $.map(ASF_forms, function(x) {
return x === form ? null : x;
});
$(window).data("ASF_forms", ASF_forms);
});
}
}); });
// activate ASF_beforeunload (if not already done) // activate ASF_beforeunload (if not already done)
if ($.fn.ASF_beforeunload) { if ($.fn.ASF_beforeunload) {
Expand Down

0 comments on commit 37ba311

Please sign in to comment.