I'm new to MarionetteJS and love it. I've created an ItemView and CompositeView to show the values within a collection. This is great, but I want to render custom field/column headers. I've done this using Backbone.Collection and using _.each(item.keys(), function(key){... I cannot does this with MarionetteJS since I am using an ItemView for each Row.
I've tried using appendHTML, but am having difficulty accessing the collection. Here's what I got so far:
...
render: function () {
var template = "<% _.each(item.keys(), function(key){%><th><%= key %></th><%})%>";
this.$("thead").html(_.template(template, {
item: this.collection.models[0]
}));
},
appendHtml: function (collectionView, itemView) {
collectionView.$("tbody").append(itemView.el);
},
...
This is not working. Any help would be appreciated.