Search code examples
knockout.jsdukescript

DukeScript: how to access the Java model from the JavaScript context?


This is related to 1 and 2.

I've read the excellent documentation "Using the Knockout API". That explains how the context is set of a specific widget with knockout bindings.

Now I'd like to be able to access Java models from the Firebug command line, as I would normally do when I access the ViewModel in Javascript using KnockoutJS in a browser. Firebug doesn't know about "$root", basically I don't know how, and whether it'd be possible at all, to access the Java model at all and call @Function methods. That would make for a cool REPL.


Solution

  • There is the ko.dataFor and ko.contextFor and it might be easier to just use Model = ko.dataFor(document.body);