DukeScript:如何从JavaScript上下文访问Java模型? [英] DukeScript: how to access the Java model from the JavaScript context?
问题描述
我已经阅读了出色的文档使用Knockout API" . 这就解释了如何设置带有剔除绑定的特定窗口小部件的上下文.
I've read the excellent documentation "Using the Knockout API". That explains how the context is set of a specific widget with knockout bindings.
现在,我希望能够从Firebug命令行访问Java模型,就像我通常在浏览器中使用KnockoutJS访问Javascript中的ViewModel一样. Firebug不了解"$ root",基本上我不知道如何访问Java模型并调用@Function方法,以及是否完全有可能. 那会很酷的REPL.
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.
推荐答案
有 ko .dataFor和ko.contextFor ,使用起来可能会更容易
Model = ko.dataFor(document.body);
There is the ko.dataFor and ko.contextFor and it might be easier to just use
Model = ko.dataFor(document.body);
这篇关于DukeScript:如何从JavaScript上下文访问Java模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!