Slide 13
Slide 13 text
Model
MyApp.Contact = Backbone.Model.extend({
defaults: {
firstname : “”,
lastname : “”,
telephone : “”
},
getFullName: function() {
return this.fullname + this.lastname;
},
validate: function(){}
});
var newContact = new MyApp.Contact();
newContact.set({‘firstname’ : ‘Lebron'});
Represents data (JSON)
Key-value attributes
Domain-specific methods
Custom events & Validation
{
“id” : 31,
“firstname” : “LeBron”,
“lastname” : “James”,
“telephone” : “111-222-3333”
}
Monday, 3 June 13