I have a simple Backbone collection that pulls a list of objects from a (remote) resource. The call Collection.fetch, however, does not complete with this error:
Object [object Object] has no method '_validate'
I assume this happens under the hood when the collection tries to instantiate a model for each JSON object when added. Can anyone shed some light on why this will happen?
Here is the code I'm using. Very bare bones ...
var SomeModel = Backbone.View.extend({});
var SomeCollection = Backbone.Collection.extend({
url: 'http://localhost:8000/api/some/resource/?format=json',
model: SomeModel,
parse: function(data) {
return data.objects
}
});
var SomeView = Backbone.View.extend({
collection: new SomeCollection(),
initialize: function() {
this.collection.fetch();
},
});
And here is an example of a resource response:
{
"meta": {
"count": 100
},
"objects": {
{"title": "Title", "id": 1},
{"title": "Title 2", "id": 2}
}
}
source
share