JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
JavaScript
var BoldGridDashboardJourneys = Backbone.Model.extend({
defaults: {
// will need to include a tie breaker attribute in both models
type: 'boldgrid_customer_journey'
}
}),
folder = Backbone.Model.extend({
defaults: {
// tie breaker
type: 'folder'
}
});
var BoldGridDashboardContent = new Backbone.Collection([
model: function (attr, options) {
switch (attr.type) {
case 'boldgrid_customer_journey':
return new file(attr, options);
break;
case 'boldgrid_inspiration_tab':
return new folder(attr, options);
break;
case 'boldgrid_customization_1_tab':
return new folder(attr, options);
break;
case 'boldgrid_customization_2_tab':
return new folder(attr, options);
break;
case 'boldgrid_customization_3_tab':
return new folder(attr, options);
break;
case 'boldgrid_advanced_wp_tab':
return new folder(attr, options);
break;
}
}
});
// after that just add models to the collection as always
new BoldGridDashboardContent([{
type: 'file',
name: 'file.txt'
}, {
type: 'folder',
name: 'Documents'
}]);