I have the following problem: My API returns null - no data available. (that's good!). My collection
gets the data but creates one single empty object.
My API result (from Firebug):
{"data":{"objects":null}}
My collection:
var MyCollection = Backbone.Collection.extend({
model: MyModel,
url: '/v1/ajax/load-objects',
parse: function(resp, xhr) {
return resp.data.objects;
}
});
When I print self.model.toJSON()
in my view (the model is the collection), I get this (by Firebug):
[Object {}]
My question: Why is the collection putting one empty bject in my collection? The API returns null, so it should be empty.
I tried adding default values to my model (which the collection uses), they are not shown. So I guess it's taking the null as the data for one object. How can I stop him doing this?
Thx
Ron