diff --git a/src/navigator/view/ItemView.js b/src/navigator/view/ItemView.js index 254f5b51f..12c158e00 100644 --- a/src/navigator/view/ItemView.js +++ b/src/navigator/view/ItemView.js @@ -67,7 +67,6 @@ module.exports = require('backbone').View.extend({ const components = model.get('components'); model.set('open', false); this.listenTo(components, 'remove add change reset', this.checkChildren); - this.listenTo(model, 'destroy remove', this.remove); this.listenTo(model, 'change:status', this.updateStatus); this.listenTo(model, 'change:open', this.updateOpening); this.listenTo(model, 'change:style:display', this.updateVisibility); diff --git a/src/navigator/view/ItemsView.js b/src/navigator/view/ItemsView.js index 2a94a775b..f9666f11c 100644 --- a/src/navigator/view/ItemsView.js +++ b/src/navigator/view/ItemsView.js @@ -16,6 +16,7 @@ module.exports = require('backbone').View.extend({ const coll = this.collection; this.listenTo(coll, 'add', this.addTo); this.listenTo(coll, 'reset resetNavigator', this.render); + this.listenTo(coll, 'remove', this.removeChildren); this.className = `${pfx}layers`; const em = config.em; @@ -44,6 +45,11 @@ module.exports = require('backbone').View.extend({ parent && this.$el.data('model', parent); }, + removeChildren(removed) { + const view = removed.viewLayer; + view.remove.apply(view); + }, + /** * Add to collection * @param Object Model