diff --git a/client/lib/bull.js b/client/lib/bull.js index 6138ada248..5bcae019bc 100644 --- a/client/lib/bull.js +++ b/client/lib/bull.js @@ -999,8 +999,16 @@ var Bull = Bull || {}; this.$el = $(el).eq(0); this.el = this.$el[0]; - } + }, + propagateEvent: function () { + this.trigger.apply(this, arguments); + + for (var key in this.nestedViews) { + var view = this.nestedViews[key]; + view.propagateEvent.apply(view, arguments); + } + }, }); }).call(this, Bull, Backbone, _); diff --git a/client/src/controller.js b/client/src/controller.js index ce4e761045..39eedd24f5 100644 --- a/client/src/controller.js +++ b/client/src/controller.js @@ -157,7 +157,13 @@ define('controller', [], function () { storeMainView: function (key, view) { this.set('storedMainView-' + key, view); - view.once('remove', function () { + + this.listenTo(view, 'remove', function (o) { + o = o || {}; + if (o.ignoreCleaning) return; + + this.stopListening(view, 'remove'); + this.clearStoredMainView(key); }, this); }, @@ -278,6 +284,10 @@ define('controller', [], function () { if (master.currentViewKey) { this.set('storedScrollTop-' + master.currentViewKey, $(window).scrollTop()); if (this.hasStoredMainView(master.currentViewKey)) { + var mainView = master.getView('main'); + if (mainView) { + mainView.propagateEvent('remove', {ignoreCleaning: true}); + } master.unchainView('main'); } }