Question

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?

No correct solution

OTHER TIPS

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top