I would like to dynamically set the font-size on the root element using a custom Knockout bindinghandler which does a calculation based on the width of the browser window.
When I tried to apply the binding, nothing seemed to happen, so I tried to apply a simple css binding:
<html data-bind="css: { bindinghandlertest: true }">
But the binding handler didn't seem to add the class.
Question: Can KO bindings only be applied to <body>
and its children?
Note: I am initializing all bindings on the whole page by simply calling ko.applyBindings();
once on DOM ready, with no parameters at all.
You can apply bindings to a specific html element as explained here
Specifically:
In you case, you can them call
by default, the DOM node is the body, as you can see from the source: