Reputation: 41605
I'm trying to add a binding in the <html>
element of the site and it doesn't seem to have any effect.
Is there any restriction applying bindings in elements outside the body element?
<html xmlns="http://www.w3.org/1999/xhtml" data-bind="css: {'visible-menu' : $root.panels.visibleMenu }">
Upvotes: 1
Views: 49
Reputation: 32212
applyBindings
defaults to using <body>
if you don't pass a root node:
rootNode = rootNode || window.document.body; // Make "rootNode" parameter optional
If you pass the <html>
node, it should work as expected. One way to do this, if you're using jQuery, is to use the :root
selector:
ko.applyBindings(viewModel, $(':root').get(0));
Or by tag name:
ko.applyBindings(viewModel, document.getElementsByTagName('html')[0]);
Upvotes: 3