[FIX] website: properly unbind events of parallax snippet option

Recent refactoring of the parallax changed the snippet option JS and
attached a callback on a editor element but forgot to detach it if
the parallax snippet is removed. This added a bug which broke the
editor every time a parallax snippet was removed.
This commit is contained in:
qsm-odoo
2016-10-18 13:14:23 +02:00
parent a40c3bf792
commit d5464458c5
@@ -311,8 +311,10 @@ options.registry.parallax = options.Class.extend({
this.$target.data("snippet-view", new animation.registry.parallax(this.$target));
}
this.scroll();
this.buildingBlock.$el.on("snippet-dropped snippet-activated", this._refresh.bind(this));
this.$target.on('snippet-option-change snippet-option-preview', this._refresh.bind(this));
this._refresh_callback = this._refresh.bind(this);
this.buildingBlock.$el.on("snippet-dropped snippet-activated", this._refresh_callback);
this.$target.on('snippet-option-change snippet-option-preview', this._refresh_callback);
},
scroll: function (type, value) {
this.$target.attr("data-scroll-background-ratio", value);
@@ -330,6 +332,11 @@ options.registry.parallax = options.Class.extend({
this._super.apply(this, arguments);
this._refresh();
},
on_remove: function () {
this._super.apply(this, arguments);
this.$target.off("snippet-option-change snippet-option-preview", this._refresh_callback);
this.buildingBlock.$el.off("snippet-dropped snippet-activated", this._refresh_callback);
},
});
options.registry.ul = options.Class.extend({