简体   繁体   中英

Identify the attribute change event in KnockoutJS?

Is there any way to identify the attribute change event in KnockoutJS?

I found solutions in jQuery: Firing event on DOM attribute change .

But it would be good if I can do it with KO.

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!!");
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM