From 6f5fc1a28a96c02de48aa6bebf48ef8b8f9c2bdf Mon Sep 17 00:00:00 2001 From: Romain Derie <rde@odoo.com> 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#100387 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> --- .../static/src/js/editor/snippets.options.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index 9a7a448452c8..440e5d7b5a24 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -1050,7 +1050,7 @@ options.registry.gallery = options.Class.extend({ this.$target.addClass('o_fake_not_editable').attr('contentEditable', false); // Make sure image previews are updated if images are changed - this.$target.on('save', 'img', function (ev) { + this.$target.on('save.gallery', 'img', function (ev) { var $img = $(ev.currentTarget); var index = self.$target.find('.carousel-item.active').index(); self.$('.carousel:first li[data-target]:eq(' + index + ')') @@ -1059,12 +1059,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 () { @@ -1101,6 +1101,13 @@ options.registry.gallery = options.Class.extend({ this.$target.removeAttr('style'); } }, + /** + * @override + */ + destroy() { + this._super(...arguments); + this.$target.off('.gallery'); + }, //-------------------------------------------------------------------------- // Options -- GitLab