I want to populate a collection from a json file that has data other than an array of data elements. I found out that the parse function in the collection should be used to return an array of data elements, but my collection is not populated from the json file. When I saved a breakpoint in the parsing method in firebug, the control does not come there.
This is my code.
var m1 = Backbone.Model.extend({ title:'Title1', tag:'html', date: 'Today' }) cll = Backbone.Collection.extend({ url:'/combodata.json?uu', model:m1, parse:function(res){ return res.items; } }); ci = new cll(); ci.fetch();
The json answer will be like this:
{ 'identifier': 'title', items:[ {title:'A', tag:"htmlcss", date:'today'}, {title:'AA', tag:"htmlcss", date:'today'}, {title:'B', tag:"htmlcss", date:'today'}, {title:'C', tag:"htmlcss1", date:'today'} ]}
Please indicate to me where I am mistaken.
rajkamal
source share