I have my View:
var TryView = Backbone.View.extend({
initialize: function(){
this.render();
},
render: function(){
var test = this.collection.get(0);
this.collection.each(function(model){
document.write(model.id+"<br>");
});
}
});
and the order to create it with some existing (working) collection.
var testView = new TryView({collection: test.TestCollection});
but i get the error:
Object function (){ parent.apply(this, arguments); } has no method ‘get’
and the same with fetch
You’re trying to call get on the ‘class’
test.TestCollection. When you do thisyou give the TestCollection ‘class’ (there are really no classes in js, just functions) as the
collection-attribute to the View. You have to give an instance of TestCollectionHope this helps!