Backbone.js: Module 6 Instantiating Collections

by emgee

HTML

<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone.js"></script>

JavaScript

var collection = new Backbone.Collection();
console.log(JSON.stringify(collection));

var Vehicles = Backbone.Collection.extend({});
collection = new Vehicles([
    new Backbone.Model({label:"A"}),
    new Backbone.Model({label:"B"})
]);

console.log(JSON.stringify(collection));