I am trying to get backbone.js to load json. The json loads but i am not sure how to get the items into my collection. Or maybe that happens automatically and i just can\'t trac
If you use rest api, try turn off these parameters:
Backbone.emulateHTTP Backbone.emulateJSON
Your json is not in the correct format, you can fix the json or add a hint to backbone in the parse method:
var ClientCollection = Backbone.Collection.extend({
defaults: {
model: Client
},
model: Client,
url: 'json/client.json',
parse: function(response){
return response.items;
}
});
Or fix your JSON:
[
{
"name": "WTBS",
"img": "no image"
},
{
"name": "XYC",
"img": "no image"
}
]