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?

没有正确的解决方案

其他提示

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)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top