Slide 60
Slide 60 text
Song = Backbone.Model.extend({
defaults: {playCount: 0},
initialize: function(){
// Setup the model here
},
displayName: function (){
// Use .get to get properties
this.get(‘artist’) + ‘: ‘ + this.get(‘track’);
},
play: function () {
//Use .set to set properties
this.set({playCount: this.get(‘playCount’) + 1});
}
});
song = new Song({artist: ‘The Fall’, track: ‘Barmy’});