[Rt-commit] rt branch, 4.2/disable-submit-buttons-on-submit, created. rt-4.1.17-146-gf863712

Ruslan Zakirov ruz at bestpractical.com
Mon Jul 29 07:46:12 EDT 2013


The branch, 4.2/disable-submit-buttons-on-submit has been created
        at  f8637121db66b6115fafe317ca73b25c0abbc3fb (commit)

- Log -----------------------------------------------------------------
commit f8637121db66b6115fafe317ca73b25c0abbc3fb
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Mar 9 01:17:32 2012 +0400

    prevent double form submit by disabling buttons
    
    Users have time to double click submit buttons and
    submit forms twice. This change disables submit buttons
    when a form is submitted. However, input is disabled
    a little bit earlier and browser wouldn't send its
    name/value pair to the server, so we add a hidden
    input.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 49344cb..c7af47c 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -124,6 +124,7 @@ sub JSFiles {
       jquery.supposition.js
       history-folding.js
       cascaded.js
+      forms.js
       event-registration.js
       late.js
       /, RT->Config->Get('JSFiles');
diff --git a/share/static/js/forms.js b/share/static/js/forms.js
new file mode 100644
index 0000000..1b6fa9a
--- /dev/null
+++ b/share/static/js/forms.js
@@ -0,0 +1,13 @@
+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.append( jQuery('<input/>', {type: "hidden", name: name, value: $this.val()} ) );
+    return true;
+  })
+});
\ No newline at end of file

-----------------------------------------------------------------------


More information about the Rt-commit mailing list