You can also do this in the main way. Check out the database of documents
In fact, you would create different models, adding in this case the link breaker attribute, say, “type”.
var file = Backbone.Model.extend({ defaults: { // will need to include a tie breaker attribute in both models type: 'file' } }), folder = Backbone.Model.extend({ defaults: { // tie breaker type: 'folder' } }); var fs = Backbone.Collection.extend({ model: function(model, options) { switch(model.type) { case 'file': return new file(model, options); case 'folder': return new folder(model, options); } } }); // after that just add models to the collection as always new fs([ {type: 'file',name: 'file.txt'}, {type: 'folder',name: 'Documents'} ]);
Geofrey Ssekirime Jul 27 '14 at 7:45 2014-07-27 07:45
source share