Knockout is open source, so you can easily check yourself if and how this may work. Take a look at the applyBindings
declaration for version 3.3.0:
ko.applyBindings = function (viewModelOrBindingContext, rootNode) {
// If jQuery is loaded after Knockout, we won't initially have access to it. So save it here.
if (!jQueryInstance && window['jQuery']) {
jQueryInstance = window['jQuery'];
}
if (rootNode && (rootNode.nodeType !== 1) && (rootNode.nodeType !== 8))
throw new Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");
rootNode = rootNode || window.document.body; // Make "rootNode" parameter optional
applyBindingsToNodeAndDescendantsInternal(getBindingContext(viewModelOrBindingContext), rootNode, true);
};
So, the second argument must be an actual node (element or comment). Just dumping in a jQuery object will most likely not work. If you use jQuery, you'll need to unwrap the jQuery object returned from the $(selector)
method, e.g. by taking the first item. Like this:
var jqueryResult = $('#root1');
var node = jqueryResult[0];
ko.applyBindings({myTxt:'testing123'}, node);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"></script>
<div id="root1"><span data-bind="text: myTxt"></span></div>
Here's another answer I wrote, with some more details about ko.applyBindings
' second argument.
PS. If you're asking a "would the following work" question, wouldn't just trying it be quicker and more informative?