1

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
SRAVAN
  • 769
  • 1
  • 7
  • 11

1 Answers1

2

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!!");
});
Matt Burland
  • 44,552
  • 18
  • 99
  • 171