I am implementing a 2 column layout view as shown below:
However it seems that when I define my marionette composite view, only a single itemViewContainer is allowed.
Can I do something like this?
class List.Muse extends Marionette.ItemView
template: JST["backbone/templates/muses/index"]
class List.Muses extends Marionette.CompositeView
template: JST["backbone/templates/muses/list"]
itemView: List.Muse
itemViewContainer: ".left_col"
itemViewContainer: ".right_col"
//list template
.muses_container.two_col_wrapper.hide
.left_col
.right_col
.clearfix
.loading_container
Essentially I would like to alternate insertion of muses into the 'left' and 'right' column in my list template. Is that possible to define in the composite view?
The Marionette
view construct that you want to use here is a Layout
. You can think of a Layout
as an ItemView
that has regions built in for rendering sub views into. Something like this is what you are after (in JS. Sorry I don't really know CS):
List.Muses = Marionette.Layout.extend({
template: JST["backbone/templates/muses/list"],
regions : {
leftColRegion : ".left_col",
rightColRegion : ".right_col"
},
onRender : function () {
this.leftColRegion.show(new List.Muse({model : someMuseModel}));
this.rightColRegion.show(new List.Muse({model : someOtherMuseModel}));
}
});