From 8a96e73cb2bfaf1bb973281e1c3033f3ecc5309f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Wed, 28 May 2014 12:27:00 +0200 Subject: [PATCH 1/1] editor: fix - remove gutter group when canvas element gets detached --- src/editor/modules/documentCanvas/canvas/documentElement.js | 3 +++ src/editor/modules/documentCanvas/canvas/gutter.js | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/editor/modules/documentCanvas/canvas/documentElement.js b/src/editor/modules/documentCanvas/canvas/documentElement.js index 8a5193b..d40ca9b 100644 --- a/src/editor/modules/documentCanvas/canvas/documentElement.js +++ b/src/editor/modules/documentCanvas/canvas/documentElement.js @@ -154,6 +154,9 @@ $.extend(DocumentNodeElement.prototype, { detach: function(isChild) { var parents; + if(this.gutterGroup) { + this.gutterGroup.remove(); + } if(_.isFunction(this.children)) { this.children().forEach(function(child) { child.detach(true); diff --git a/src/editor/modules/documentCanvas/canvas/gutter.js b/src/editor/modules/documentCanvas/canvas/gutter.js index b6bd665..472998a 100644 --- a/src/editor/modules/documentCanvas/canvas/gutter.js +++ b/src/editor/modules/documentCanvas/canvas/gutter.js @@ -42,11 +42,13 @@ var GutterGroupView = function(gutterView, group) { this.group.on('viewAdded', this.onViewAdded, this); this.group.on('focusToggled', this.onFocusToggled, this); + this.group.on('removed', this.remove, this); }; $.extend(GutterGroupView.prototype, { remove: function() { this.group.off('viewAdded', this.onViewAdded); this.group.off('focusToggled', this.onFocusToggled); + this.group.off('removed', this.removed); this.dom.detach(); }, onViewAdded: function(view) { @@ -84,6 +86,9 @@ $.extend(ViewGroup.prototype, Backbone.Events, { }, show: function() { this.gutter.show(this); + }, + remove: function() { + this.trigger('removed'); } }); -- 2.20.1