Friday, 11 December 2015

Exercise-10:Listening for changes to Model

Solution

Override  initialize method of Model with following code

initialize: function(){
console.log("model initialized");
this.on("change:name", function(e){console.log( "Mr"+e.get('name'));});
}

Instantiate model and watch console. You should see console with value "Mr.Jain Sood"

person.set('name','Jain Sood'));


No comments:

Post a Comment