Archive for the ‘Marionette’ category

How to dynamically set the template in a Marionette ItemView

December 28th, 2012

Don’t judge me on this, I am just trying to offer some help, this took me a lot longer to figure out that it should have, but I am glad I figured it out and I thought I would throw this out there for anybody else struggling with it too. I beat my head into the wall trying to set the template for an itemview and it turns out it was stupid simple, as outlined in the code below:

var v = new this.options.itemsView({
    collection: l,
    itemView: yourItemView.extend({ template: "<div>yourTemplate</div>" })
});
//show it in your region
this.listing.show(v);

As you can see, all you have to do is use the extend method of the itemView and set the template inside of that and voila. This may not be the recommended way of getting this done but it works for me and its nice and simple and allows for some very clean code. I hope this helps someone, enjoy!!

Creating a grouped tablerow using Twitter Bootstrap and Backbone Marionette

November 9th, 2012

I have been working on a project where I need data grouped or summarized by date, and I wanted to make use of Backbone and Marionette with its CompositeViews and ItemViews so I whipped up an example, check it out below

It makes use of a Marionette CompositeView to create a table and then takes that and an ItemView to create rows that are wrapped with the Twitter Bootstrap accordion control to do the collapsing of the rows, how sweet is that??