Reputation: 329
I have KO custom binding on an input element and need it to detect if there's been a change (or addition) of a css class for that element. Is this something I detect using a custom binding, or not?
Upvotes: 0
Views: 649
Reputation: 5317
It is usually not a good idea to mix Knockout and other methods to manipulate the DOM.
So in your case it is probably a better idea to set the CSS class using knockout maybe with a computed. See knockout js css multiple class bindings
If the class manipulation is outside your control (for example because it is done by an external plugin). Then you can use something like the Attr change jquery plugin to detect the DOM change and then set an observable with the result (which can then be detected by your custom binding)
Upvotes: 2