I am learning backbone.js
. I found the following code from backbone.js documentation.
//cretaing class name as Sidebar with extends Backbone.Model class
var Sidebar = Backbone.Model.extend({
promptColor:function() {
var cssColor = prompt("Please enter a CSS color:");
this.set({color1: cssColor});
}
});
//cretaing object for Sidebar class
var sidebarObject = new Sidebar();
//following statement not understand
sidebarObject.on("change:color1", function(model, color23) {
$('#body1').css({background: color23})
});
What I understand :
whenever attribute color1
will change automatically model('Slidebar') triggers sidebarObject.on()
.
What I didn't understand :
- we are passing 2 arguments names are
model,color23
to second argument of thesidebarObject.on()
. I didn't understand anything about that arguments.
2.As per my understanding model is Sidebar
in my example.Is it right.
can anyone help me.
Thanks.