If I have a model with some parameters that are collections, as an example:
var Mdl = Backbone.Model.extend({
defaults:{
test: new Backbone.Collection()
}
});
Now lets say I do a fetch on this model, and in my server side response I have a property called "test" which is an array. I would like to add the array to my collection or reset it with this array so that it remains a backbone collection, however this is not done by default if I run a reset on my model, as expected, it will overwrite the "test" property with the array in the response.
What is the best way to get it to treat the response property "test" as a backbone collection instead of array? I basically want to check if the property is an array, then check if the property is already defined on the model as a collection, if so then reset this collection with the array rather then overwriting it.
I could do this by creating my own Backbone Sync, but I am not sure if this is the best way togo about it, what do you guys think?
Thanks.
responsedocumentcloud.github.com/backbone/#Model-parse you will have to write code to do what you want now - Deeptechtonsnew Backbone.Collection()i rather create a instance of the collection like below.var tstCol = Backbone.Collection.extend({}); ... defaults:{test:new tstCol()}...- Deeptechtons