![](/img/trans.png)
[英]Listen events relative to the @el with backbone.js in the event attribute of a view
[英]Attaching a Backbone.js event to a view based on the model attribute
我是Backbone.js的新手。 基本上,我有一個模型屬性“修改”。 我只想檢查其值是否為true並相應地更新視圖。 我已經在視圖中嘗試過類似的方法。
this.model.on("change:modified", function() {
self.$el.show();
});
要么
this.model.on("modified:true", function() {
self.$el.show();
});
我已經檢查過在使用console.log(this.model)時,它包含“ modified”作為屬性之一。
你可以做這樣的事情。
this.listenTo(this.model, "change:modified", function(){
self.$el.show();
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.