[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) <qsm@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Romain Derie
2022-09-23 11:22:21 +02:00
committed by qsm-odoo
parent 817be4899d
commit 071de693ca
@@ -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