From 84d0eee76e5e6fdcf2986e4b503065a786b6f8e4 Mon Sep 17 00:00:00 2001 From: Paul Falgout Date: Fri, 11 Nov 2016 16:41:18 +0900 Subject: [PATCH] emptyRegion fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Until https://github.com/marionettejs/backbone.marionette/pull/3247 is in, the `_parent` here will skip over the `CollectionView` and trigger on any `View` above the `CollectionView`. For that reason, currently setting the `_parent` here is a bad idea and users will have to listen to the `emptyRegion` or `emptyRegion.currentView`. Until a CollectionView can be treated as a parent of a Region we should leave this line out 😿 Additionally the emptyRegion should be destroyed on clean up --- src/next-collection-view.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/next-collection-view.js b/src/next-collection-view.js index bf52a2f8f9..739e587c54 100644 --- a/src/next-collection-view.js +++ b/src/next-collection-view.js @@ -69,9 +69,7 @@ const CollectionView = Backbone.View.extend({ // Create an region to show the emptyView _initEmptyRegion() { - this.emptyRegion = new Region({ el: this.el }) - - this.emptyRegion._parent = this; + this.emptyRegion = new Region({ el: this.el }); }, // Configured the initial events that the collection view binds to. @@ -660,6 +658,7 @@ const CollectionView = Backbone.View.extend({ // called by ViewMixin destroy _removeChildren() { this._destroyChildren(); + this.emptyRegion.destroy(); }, // Destroy the child views that this collection view is holding on to, if any