私は次のようなバックボーンモデルを持っています-
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});
ここで、コールバック changeProp1 は、prop1 がtrue -> false -> trueに変更されるたびにトリガーされます。しかし、同じ値または異なる値を設定しているときはいつでも聞きたいです。