[FIX] website_sale: can't send coupon code after an ajax request

Before this commit, an user could only use the coupon form if he didn't perform
any ajax request (eg: change quantity, already sent a code..).
Since the cart html would be reinjected with theses ajax requests, the click
event would not work afterward until the page got fully reload.

Now, we changed the jquery click binding to work with dynamically injected DOM
This commit is contained in:
Romain Derie
2018-01-11 15:28:31 +01:00
parent 411a9fa326
commit 3ec98ae6b0
2 changed files with 3 additions and 2 deletions
@@ -215,7 +215,7 @@ odoo.define('website_sale.website_sale', function (require) {
return false;
});
$('.oe_website_sale .a-submit, #comment .a-submit').off('click').on('click', function (event) {
$('.oe_website_sale, #comment').off('click', '.a-submit').on('click', '.a-submit', function (event) {
if (!event.isDefaultPrevented() && !$(this).is(".disabled")) {
event.preventDefault();
$(this).closest('form').submit();
@@ -35,7 +35,7 @@ $('.oe_website_sale #add_to_cart, .oe_website_sale #products_grid .a-submit')
$(this).remove();
});
$modal.on('click', '.a-submit', function () {
$modal.on('click', '.a-submit', function (ev) {
var $a = $(this);
$form.ajaxSubmit({
url: '/shop/cart/update_option',
@@ -50,6 +50,7 @@ $('.oe_website_sale #add_to_cart, .oe_website_sale #products_grid .a-submit')
}
});
$modal.modal('hide');
ev.preventDefault();
});
$modal.on('click', '.css_attribute_color input', function (event) {