【问题标题】:Identify the attribute change event in KnockoutJS?识别 KnockoutJS 中的属性更改事件?
【发布时间】:2012-10-12 09:36:29
【问题描述】:

KnockoutJS中有什么方法可以识别属性改变事件吗?

我在 jQuery 中找到了解决方案: Firing event on DOM attribute change .

但如果我能用 KO 就更好了。

【问题讨论】:

    标签: javascript knockout.js dom-events custom-attributes knockout-2.0


    【解决方案1】:

    如果属性更改绑定到视图模型中的某个属性,那么您只需订阅该属性即可获得更改通知。

    myViewModel.myProperty.subscribe(function(newValue) {
        alert("This property changed!!");
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-23
      • 2018-10-01
      • 2012-06-26
      • 1970-01-01
      • 1970-01-01
      • 2020-01-26
      • 2011-05-09
      • 2011-06-08
      相关资源
      最近更新 更多