Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Backbone Model+Collection Minimal


var Person = Backbone.Model.extend({
   /*defaults:{}*/
});

var Persons = Backbone.Collection.extend({
/*model: Person*/

});

var person1 = new Person({name: "Jim Smith"});
var personsCollection =  new Persons();
/*don't add a {} in the Persons()*/
personsCollection.add([person1]);

console.log(personsCollection.models[0].get("name"));
 
PREVIOUS NEXT
Tagged: #Backbone #Minimal
ADD COMMENT
Topic
Name
9+4 =