From ed73a0187d3b000251a93eb440266cf257cf11f9 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Thu, 21 Sep 2017 11:26:22 +0200 Subject: [PATCH] SUPPORT-1227: Prevented multiple submits of a form --- themes/loop/loop.info | 1 + themes/loop/scripts/form.js | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 themes/loop/scripts/form.js diff --git a/themes/loop/loop.info b/themes/loop/loop.info index 758c1914..6a1f1649 100644 --- a/themes/loop/loop.info +++ b/themes/loop/loop.info @@ -16,6 +16,7 @@ scripts[] = scripts/modernizr.min.js scripts[] = scripts/chosen.jquery.js scripts[] = scripts/use-chosen.min.js scripts[] = scripts/toggle.js +scripts[] = scripts/form.js ; Stylesheets stylesheets[all][] = css/styles.css diff --git a/themes/loop/scripts/form.js b/themes/loop/scripts/form.js new file mode 100644 index 00000000..0ea62224 --- /dev/null +++ b/themes/loop/scripts/form.js @@ -0,0 +1,11 @@ +(function($) { + $(function () { + // Disable all submit buttons on submit to prevent multiple + // submits. + // Using the "submit" event on the form is too slow (late), so we + // use the "click" event on the button itself. + $('form [type="submit"]').on('click', function() { + $(this).closest('form').find('[type="submit"]').prop('disabled', true); + }); + }); +})(jQuery);