Is it possible to have a composite view in marionette with DIFFERENT item views inside? For example:
var myCompositeView = Backbone.Marionette.CompositeView.extend({
template: Handlebars.compile(myTemplate),
itemView: myView, // I want different views, not just myView
initialize: function(){
this.collection = this.model.views;
},
appendHtml: function(collectionView, itemView){
collectionView.$('.container').append(itemView.el);
}
});
Basically, depending on the model in the collection, I want to create a certain view.
You'll want to override the
buildItemView
method:You can accomplish this with the getItemView method:
Here item means the model in the collection. Hope this helps.