I'm new to Backbone JS and have been following Christopher Coenraets Wine Cellar tutorial.
It all works fine and dandy but I don't understand how he is using this.model.models
to access a collection rather than this.collection
. Furthermore when I try changing the code to the latter it appears that this.collection
is undefined.
window.WineListView = Backbone.View.extend({
tagName:'ul',
initialize:function () {
this.model.bind("reset", this.render, this);
},
render:function (eventName) {
_.each(this.model.models, function (wine) {
$(this.el).append(new WineListItemView({model:wine}).render().el);
}, this);
return this;
}
});