[Rt-commit] rt branch 5.0/prevent-ticket-double-click created. rt-5.0.4-230-g9f8512096c
BPS Git Server
git at git.bestpractical.com
Wed Sep 27 18:13:57 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/prevent-ticket-double-click has been created
at 9f8512096c926d0447fd3b29f67943dde183f910 (commit)
- Log -----------------------------------------------------------------
commit 9f8512096c926d0447fd3b29f67943dde183f910
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Tue Sep 26 11:22:12 2023 -0400
Prevent double-clicking from submitting forms multiple times
Some users double-click form buttons rather than single
clicking as expected and on some forms in some browsers,
this can cause double updates. For example, double clicking
on a ticket comment/reply can post the response twice.
Other forms such as searches might just run the search
twice, using extra server resources needlessly.
Allow all forms to be submitted only once by adding a
CSS class as a flag to indicate the form has been
submitted.
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 1c8a1aa6aa..6d8ddf76c3 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -1005,6 +1005,22 @@ jQuery(function() {
);
return false;
});
+
+ // Submit all forms only once.
+ // This stops all forms of double-clicking or double
+ // enter/return key.
+ jQuery('form').each(function() {
+ var form = jQuery(this);
+ form.on('submit', function (e) {
+ // Prevent if already submitting
+ if (form.hasClass('rt-form-submitted')) {
+ e.preventDefault();
+ }
+
+ // Add class to hook our visual indicator on
+ form.addClass('rt-form-submitted');
+ });
+ });
});
function filterSearchResults () {
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list