From 809aaf9e7b9de28383444d5059b19a67bb513f51 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Thu, 26 Oct 2017 17:02:14 +0200 Subject: [PATCH] [FIX] website_event: avoid double subscription Before this commit, you was able to double click on the button when are in registration flow. In this case, you subscribe 2 times and so take 2x more seats, what can be annoying when you have a limited room. In the same time, we fix the form in the form that generate strange behaviour like some events not bubbled correctly. The attendee form (into the modal) was inside the registration form. $'attendee_form).on('submit') obviously failed due to this bad dom. This commit closes opw-778191 --- addons/website/static/src/js/website.js | 2 +- addons/website_event/static/src/js/website_event.js | 4 +++- addons/website_event/views/website_event.xml | 4 ++-- .../views/website_event_questions_templates.xml | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/website/static/src/js/website.js b/addons/website/static/src/js/website.js index 4e5b805fa8c..c353590510e 100644 --- a/addons/website/static/src/js/website.js +++ b/addons/website/static/src/js/website.js @@ -228,7 +228,7 @@ base.ready().then(function () { init_kanban(this); }); - $('.js_website_submit_form').on('submit', function() { + $('body').on('submit', '.js_website_submit_form', function() { var $buttons = $(this).find('button[type="submit"], a.a-submit'); _.each($buttons, function(btn) { $(btn).attr('data-loading-text', ' ' + $(btn).text()).button('loading'); diff --git a/addons/website_event/static/src/js/website_event.js b/addons/website_event/static/src/js/website_event.js index 3b2248742a9..b5a31ae7950 100644 --- a/addons/website_event/static/src/js/website_event.js +++ b/addons/website_event/static/src/js/website_event.js @@ -9,6 +9,7 @@ $(document).ready(function () { .off('click') .removeClass('a-submit') .click(function (ev) { + $(this).attr('disabled', true); ev.preventDefault(); ev.stopPropagation(); var $form = $(ev.currentTarget).closest('form'); @@ -18,7 +19,8 @@ $(document).ready(function () { }); ajax.jsonRpc($form.attr('action'), 'call', post).then(function (modal) { var $modal = $(modal); - $modal.appendTo($form).modal(); + $modal.find('.modal-body > div').removeClass('container'); // retrocompatibility - REMOVE ME in master / saas-19 + $modal.after($form).modal(); $modal.on('click', '.js_goto_event', function () { $modal.modal('hide'); }); diff --git a/addons/website_event/views/website_event.xml b/addons/website_event/views/website_event.xml index 69701ce0056..a1c7e8e0588 100644 --- a/addons/website_event/views/website_event.xml +++ b/addons/website_event/views/website_event.xml @@ -441,7 +441,7 @@