summaryrefslogtreecommitdiff
path: root/addons/website_form/static/src
diff options
context:
space:
mode:
authorDavid Monjoie <dmo@odoo.com>2016-04-26 11:16:37 +0200
committerDavid Monjoie <dmo@odoo.com>2016-04-26 12:07:30 +0200
commit02fd74a3faa248483bdc6b4ca9fd0b4dc05557bc (patch)
treef8cf49a1b2013c399b2caa8916bf7ec5ded965e2 /addons/website_form/static/src
parent58a5b5e453e39f1e334f4d7d4a89c9c4e3a790c2 (diff)
[FIX] website_form: prevent users from crazy clicking
If the feedback of a form is too slow, people might be tempted to click a second time, trigerring a second request. If, after that, the result has not been received yet, the user might be tempted to click a lot of time because he is angry at such slowness. This behavior would trigger a record creation each time the user clicked the submit button. This fix disables the button once it has been clicked once, and re-enable it if the record could not be created, which means that there was an error in the input and the user needs to change the values and try again. The button has been changed to a span to avoid the default browser behavior to post the form when no function is bound on the send button.
Diffstat (limited to 'addons/website_form/static/src')
-rw-r--r--addons/website_form/static/src/js/website_form.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/addons/website_form/static/src/js/website_form.js b/addons/website_form/static/src/js/website_form.js
index cea891ef135..ad5dcaa5cb7 100644
--- a/addons/website_form/static/src/js/website_form.js
+++ b/addons/website_form/static/src/js/website_form.js
@@ -47,6 +47,7 @@ odoo.define('website_form.animation', function (require) {
send: function(e) {
e.preventDefault(); // Prevent the default submit behavior
+ this.$target.find('.o_website_form_send').off(); // Prevent users from crazy clicking
var self = this;
@@ -211,6 +212,10 @@ odoo.define('website_form.animation', function (require) {
},
update_status: function(status) {
+ var self = this;
+ if (status != 'success') { // Restore send button behavior if result is an error
+ this.$target.find('.o_website_form_send').on('click',function(e) {self.send(e);});
+ }
this.$target.find('#o_website_form_result').replaceWith(qweb.render("website_form.status_" + status))
},
});