使用jstree打开一个节点及其所有父节点

编程入门 行业动态 更新时间:2024-10-26 08:31:53
本文介绍了使用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打开一个节点及其所有父节点

本文发布于:2023-11-24 05:22:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624101.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:节点   jstree

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!