summaryrefslogtreecommitdiff
path: root/addons/website_form/static
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 11:21:20 +0200
commit6e3389ca73f2bbf97a9b706d8fc5d0af21f95006 (patch)
treeeca825586c222274d002e77d4fbff3ae9d0c4b16 /addons/website_form/static
parentda60ca91cc446c10eda5cbfc451cf5501f30a81d (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')
-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))
},
});