From 071de693cab279539ba660db5efe183b7e5efa36 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 16 Sep 2022 13:01:26 +0000 Subject: [PATCH] [FIX] website: remove the handler in the destroy What is done in start should be undone in the destroy. closes odoo/odoo#100904 X-original-commit: a221342ca18db892153bbf4139c0bee7cd1e9bde Signed-off-by: Quentin Smetz (qsm) Signed-off-by: Romain Derie (rde) --- .../static/src/snippets/s_image_gallery/options.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/website/static/src/snippets/s_image_gallery/options.js b/addons/website/static/src/snippets/s_image_gallery/options.js index 070c2df6fd7..50773955455 100644 --- a/addons/website/static/src/snippets/s_image_gallery/options.js +++ b/addons/website/static/src/snippets/s_image_gallery/options.js @@ -17,7 +17,7 @@ options.registry.gallery = options.Class.extend({ var self = this; // Make sure image previews are updated if images are changed - this.$target.on('image_changed', 'img', function (ev) { + this.$target.on('image_changed.gallery', 'img', function (ev) { var $img = $(ev.currentTarget); var index = self.$target.find('.carousel-item.active').index(); self.$('.carousel:first li[data-bs-target]:eq(' + index + ')') @@ -26,12 +26,12 @@ options.registry.gallery = options.Class.extend({ // When the snippet is empty, an edition button is the default content // TODO find a nicer way to do that to have editor style - this.$target.on('click', '.o_add_images', function (e) { + this.$target.on('click.gallery', '.o_add_images', function (e) { e.stopImmediatePropagation(); self.addImages(false); }); - this.$target.on('dropped', 'img', function (ev) { + this.$target.on('dropped.gallery', 'img', function (ev) { self.mode(null, self.getMode()); if (!ev.target.height) { $(ev.target).one('load', function () { @@ -73,6 +73,13 @@ options.registry.gallery = options.Class.extend({ this.$target.removeAttr('style'); } }, + /** + * @override + */ + destroy() { + this._super(...arguments); + this.$target.off('.gallery'); + }, //-------------------------------------------------------------------------- // Options