javascript JsTree如何创建根节点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11756133/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 14:13:37  来源:igfitidea点击:

JsTree how to create a root node

javascriptjstree

提问by sokid

How to create a root node using 'create' method

如何使用“create”方法创建根节点

Root
 |___ Child1
 |___ Child2

I am using JsTree, by using 'json_data' I can able to create nodes, but I want to create all nodes dynamically using 'create' method.

我正在使用 JsTree,通过使用 'json_data' 我可以创建节点,但我想使用 'create' 方法动态创建所有节点。

Please help me....

请帮我....

回答by L S

As of version 3.0.0-beta10 of jsTree, to create a top-level node, the reference for the parent is "#". For example:

从 jsTree 3.0.0-beta10 版本开始,要创建顶级节点,父节点的引用是"#". 例如:

$("#jstree").jstree('create_node', '#', {'id' : 'myId', 'text' : 'My Text'}, 'last');

The older answer given here didn't work with that version of jsTree.

此处给出的旧答案不适用于该版本的 jsTree。

回答by Danil Speransky

Maybe it is what you are looking for:

也许这就是你要找的:

$("#tree").jstree("create", -1, false, "Name", false, true);