本文介绍了使用jstree打开一个节点及其所有父节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用jstree并在打开页面时打开一个节点及其所有父节点.这是我用来测试的html代码.
I'm trying to use jstree and let one node and all its parent be opened when the page is opened. Here is the html code I used to test.
<div id="treeTask"> <ul> <li id="node_37"><a href="#">TEST1</a> <ul> <li id="node_38"><a href="#">TEST2</a></li> <li id="node_39"><a href="#">TEST3</a></li> </ul> </li> </ul> <ul> <li id="node_3"><a href="#">TEST1</a> <ul> <li id="node_4"><a href="#">TEST2</a></li> <li id="node_6"><a href="#">TEST3</a></li> </ul> </li> </ul> </div>这是初始化jstree并打开节点的调用.
And here is the call to initialize jstree and open the node.
$(function () { $("#treeTask").jstree(); $("#treeTask").bind("ready.jstree", function (event, data) { $("#treeTask").jstree("open_node", $("#node_4")); if((data.inst._get_parent(data.rslt.obj)).length) { data.inst._get_parent(data.rslt.obj).open_node(this, false); } }); });我已经处理了一段时间的代码,但无法使其正常工作.如果有人可以提供帮助,我将不胜感激.
I have been manipulating the code for a while, but could not make it work. I would really appreciate if anyone can help.
非常感谢!
推荐答案您可以使用内置的_open_to函数: www.jstree/api/#/?q= open_to& f = _open_to%28obj%29
You can use the built-in _open_to function: www.jstree/api/#/?q=open_to&f=_open_to%28obj%29
$("#treeTask").jstree().bind('ready.jstree', function (event, data) { data.instance._open_to('node_4'); });更多推荐
使用jstree打开一个节点及其所有父节点
发布评论