[Rt-commit] rt branch, 4.2/avoid-disabling-submit-buttons, created. rt-4.2.3-87-gb31fac3
? sunnavy
sunnavy at bestpractical.com
Tue Apr 22 11:43:36 EDT 2014
The branch, 4.2/avoid-disabling-submit-buttons has been created
at b31fac31f63439616405a123199dc449875d7517 (commit)
- Log -----------------------------------------------------------------
commit b31fac31f63439616405a123199dc449875d7517
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Apr 22 22:35:50 2014 +0800
refactor "prevent double submission" js code to not disable submit buttons
if you are going back to a page which contains those disabled buttons, they
stay disabled and clicking them results nothing. see also #27489
this commit makes sure the forms in page(even if you are going back to it)
could be submitted
diff --git a/share/static/js/forms.js b/share/static/js/forms.js
index 57132be..1ff7b36 100644
--- a/share/static/js/forms.js
+++ b/share/static/js/forms.js
@@ -1,13 +1,17 @@
jQuery(function() {
- jQuery('form').submit(function() {
- jQuery(this).find('input[type="submit"]').attr('disabled','disabled');
- return true;
- })
- jQuery('input[type="submit"]').click(function() {
- var $this = jQuery(this);
- var name = $this.attr('name');
- if (!name) { return true; }
- $this.after( jQuery('<input/>', {type: "hidden", name: name, value: $this.val()} ) );
- return true;
- })
-});
\ No newline at end of file
+ // reset form submit info when user goes backward or forward for Safari
+ if ( window.addEventListener ) {
+ window.addEventListener("popstate", function(e) {
+ jQuery('form').data('submitted', false);
+ });
+ }
+
+ jQuery('form').submit(function(e) {
+ var form = jQuery(this);
+ if (form.data('submitted') === true) {
+ e.preventDefault();
+ } else {
+ form.data('submitted', true);
+ }
+ });
+});
-----------------------------------------------------------------------
More information about the rt-commit
mailing list