Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Wrong Model Name For Backbone: Code Still Runs


 
 var Person = Backbone.Model.extend({
  defaults:{
    name:"John Smith"
  }
 });

var Fruit = Backbone.Model.extend({
  defaults:{
    name: "Apple"
  }
})

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

 });

var person1 = new Person({name:"Jim Smith"});
var personsCollection = new Persons();
var fruit1 = new Fruit({name: "Orange"});
personsCollection.add([fruit1]);
console.log(personsCollection.models[0].get("name"));
 
PREVIOUS NEXT
Tagged: #Wrong #Model #Name #For #Code #Still #Runs
ADD COMMENT
Topic
Name
7+1 =