backbone.js modify specific fields of model after fetch the collection -


var items=[{"endsat": "2013-05-26t07:00:00z","id": 1,"name": "niuniu1"}, {"endsat": "2013-05-26t07:00:00z","id": 2,"name": "niuniu2"}]  itemmodel=backbone.model.extend({}); itemcollection=backbone.collection.extend({     model:itemmodel,     url: '...',      parse: function(response) {        return response.items;     }  }) 

if have series of data items, when build model, each model, it's endat "2013-05-26t07:00:00z". can modify model or data process "2013-05-26"?

i foreach loop inside collection process date, i'm wondering if there better pracitce parse inside model?

thanks!

the practice use 1 said you've thought - implementing custom parse on model. documentation states, called after sync. see here: http://backbonejs.org/#model-parse

itemmodel = backbone.model.extend({     parse: function(response,options) {        //perform work on 'response',         //    return attributes model should have.     }; }) 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -