I have a model fetch from a JSON file.
var TemplateModel = Backbone.Model.extend ({
// JSON URL
urlRoot: 'json file url',
// Fetch on initialize.
initialize:function startModel(){
this.fetch();
},
// Defaults
defaults: {
/** Defaults. **/
}
});
The thing i want to do is to get some Array of objects from the json fetched and load this array to a collection.
var templatesModel = new TemplateModel();
var constants = templatesModel.get('constants');
var constantsCollection = new Backbone.Collection.extend({model: constants});
But i receive multiple errors.
¿Any idea how can i filter a model and fill with the filtered data a Collection?
Thanks in advance