First – I’m new to Backbone, so bear with the possibly stupid nature of this question. I have a model:
var AppModel = Backbone.Model.extend({
defaults: {
mynumber: null
}
});
I can successfully add items dynamically to the collection (console.log shows that they’re going in fine), but I’m just not sure how to pull them out, here’s what I’m trying:
printCollection: function(){
this.collection.each(function(item){
console.log(item.mynumber);
});
}
Which shows the number of items and undefined.
You need to use the attribute accessor, not the value.