Is there a way to get knockout to ignore the bindings even though apply bindings has been called on the page?
for example
<!-- ko with: ignore-->
<span title="City" data-bind="text: city"></span>
etc..
<!-- /ko -->
I’m getting errors in the page and it would be nice to wrap areas up until the model is ready.
I wouldn’t do it this way normally but I have a lot of views with the data-bind directives in place.
return (new Function("sc", functionBody))(scopes);
uncaught exception: [Exception... "'Error: Unable to parse bindings.
Message: ReferenceError: city is not defined;
knocko...ebug.js (line 195)
As for me your problem caused by application’s architecture. I could propose workarounds for problem
with: undefinedwill not parse bindings. However elements will disappear from DOM and will never appear them since you have no way to re-evaluatewithbindingif: IsViewModelReadybinding. Setwindow.IsViewModelReady(true)when you are ready to bind. Checkout example: http://jsfiddle.net/romanych/6Wwux/However my suggestion is to call
ko.applyBindings()when all data needed for first render is ready. Also I want to notice thatko.applyBindingstakes second argumentcontainerwhich defines DOM node to start scanning fordata-bindattributes. You could apply binding to each part of page when you are ready. Check this sample: http://jsfiddle.net/romanych/4AjBA/