Using knockout.js on our current project, we came to this point several times already.
How can I make sure some piece of Javascript code gets executed only after all bindings on the page have been applied by Knockout?
In my specific use case, I am using if
-bindings to evaluate some configuration options and decide whether the elements inside should be rendered (= in the DOM) or not. Only after these if
-bindings have been evaluated I need to count the number of DOM nodes inside a certain element. Obviously, if I count too early the if
-bindings have not removed those unwanted DOM nodes yet, so the counting comes to a wrong result.