Slide 29
Slide 29 text
Model <-> View (ൺֱ༻Backbone)
var
SomeView
=
Backbone.View.extend({
initialize:
function(){
this.model.on("change",
this.render);
},
events:
{
"click
.button"
:
"changeState"
},
changeState:
function(e){
this.model.set("item",
$(e.target).val());
},
render:
function(){
$(this.el).empty().html(
_.template(
$("#template").html(),
this.model.toJSON()
)
);
}
});