我有一个骨干模型,例如-
ModelA = Backbone.Model.extend({
this.set("prop1",true);
})
并查看-
ViewA = Backbone.View.extend({
initialize : function(){
this.listenTo(this.model,"change:prop1",this.changeProp1)l;
this.model.set("prop1",true);
},
changeProp1 : function(){
// callback doesn't call because I'm setting the same value
}
});
var model1 = new ModelA();
var view1 = new ViewA({model:model1});
每当 prop1 从true -> false -> true更改时,回调 changeProp1 就会触发。但是每当我设置相同的值或不同的值时,我都想听。