Identify the attribute change event in KnockoutJS?

自古美人都是妖i 提交于 2019-12-24 15:25:03

问题


Is there any way to Identify the attribute change event in KnockoutJS?? I found solutions in jQuery: firing event on DOM attribute change firing event on DOM attribute change

But It would be good If I can do it with KO.

Thanks.


回答1:


If the attribute change is bound to a property in your view model, then you can simply subscribe to that property to get notified of changes.

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


来源:https://stackoverflow.com/questions/13013761/identify-the-attribute-change-event-in-knockoutjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!