且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何以编程方式选择特定节点?

更新时间:2023-02-08 19:06:36

由于没有答案对我有用,所以只想在这里打电话.最终DID的工作非常简单:

Just wanted to chime in here as none of the answers worked for me. What finally DID work was very simple:

$('#someTree').jstree('select_node', 'someNodeId');

请注意,我没有将someNodeId初始化为jQuery对象.这只是一个普通的字符串.

Note that I didn't initialize someNodeId as a jQuery object. It's just a plain string.

我在没有加载树的情况下就这样做了( ),因为似乎没有必要,将其置于就绪"绑定事件中.

I did this right after a tree was loaded without putting it into a "ready" bind event as it seems to not be necessary.

希望它能从几个令人沮丧的时间中节省一些时间. .

Hope it saves some one from a few frustrating hours. . .

要在树被加载后挂接到树上:

To hook into the tree after it has been loaded:

.on('loaded.jstree', function() {
    // Do something here...
  });