Skip to content

Instantly share code, notes, and snippets.

@paulfalgout
Created April 2, 2017 15:05
Show Gist options
  • Save paulfalgout/e55bb0813e2d45e4cbc42801f2d9412a to your computer and use it in GitHub Desktop.
Save paulfalgout/e55bb0813e2d45e4cbc42801f2d9412a to your computer and use it in GitHub Desktop.
NextCompositeView Alt
var NextCompositeView = Marionette.NextCollectionView.extend({
constructor: function(options) {
Marionette.NextCollectionView.call(this, options);
this.templateView = new Marionette.View(_.pick(this, ['el','template','ui','model']));
},
childView: function() {
return this.constructor;
},
getChildViewContainer: function() {
var selector = _.result(this, 'childViewContainer');
return selector ? this.findEls(selector, this.$el) : this.$el;
},
onBeforeRender: function() {
this.templateView.render();
this.$childViewContainer = this.getChildViewContainer();
},
attachHtml: function(collectionView, els) {
this.appendChildren(this.$childViewContainer, els);
},
onBeforeDestroy: function() {
this.templateView.destroy();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment