Skip to content

Instantly share code, notes, and snippets.

@paulfalgout
Created April 2, 2017 14:48
Show Gist options
  • Save paulfalgout/1826e3324d004e2b5f50c28e75fcce06 to your computer and use it in GitHub Desktop.
Save paulfalgout/1826e3324d004e2b5f50c28e75fcce06 to your computer and use it in GitHub Desktop.
Make a CompositeView with NextCollectionView
var MixinFromView = _.pick(Marionette.View.prototype, 'serializeModel', 'getTemplate', '_renderTemplate', 'mixinTemplateContext', 'attachElContent');
var NextCompositeView = Marionette.NextCollectionView.extend({
childView: function() {
return this.constructor;
},
serializeData: function() {
return this.serializeModel();
},
getChildViewContainer: function() {
var selector = _.result(this, 'childViewContainer');
return selector ? this.findEls(selector, this.$el) : this.$el;
},
onBeforeRender: function() {
this._renderTemplate();
this.bindUIElements();
this.$childViewContainer = this.getChildViewContainer();
},
attachHtml: function(collectionView, els) {
this.appendChildren(this.$childViewContainer, els);
}
});
_.extend(NextCompositeView.prototype, MixinFromView);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment