Javascript jstree create_node 的参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6871698/
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
parameters of jstree create_node
提问by Artur Keyan
Could you please give me the list of parameters of this function and an example of usage
能否请您给我这个函数的参数列表和用法示例
$('#treepanel').jstree("create_node");
回答by olafure
IMHO jsTree is powerful, but documentation could be improved.
恕我直言,jsTree 功能强大,但文档可以改进。
The create_node function is documented here.
Be careful not interpreting the [] as a literal. They are just to indicate that the parameters are optional.
注意不要将 [] 解释为文字。它们只是为了表明参数是可选的。
This works for jsTree version "pre 1.0 fixed":
这适用于 jsTree 版本“pre 1.0 fixed”:
var position = 'inside';
var parent = $('#your-tree').jstree('get_selected');
var newNode = { state: "open", data: "New nooooode!" };
$('#your-tree').jstree(
"create_node", parent, position, newNode, false, false);
JSTree 3.3.5
JSTree 3.3.5
From their docs "create_node" functionality has inverted args 'newNode' and 'position'
从他们的文档中,“create_node”功能反转了 args 'newNode' 和 'position'
$('#your-tree').jstree("create_node", parent, newNode, position, false, false);
https://www.jstree.com/api/#/?f=create_node([par,%20node,%20pos,%20callback,%20is_loaded])
https://www.jstree.com/api/#/?f=create_node([par,%20node,%20pos,%20callback,%20is_loaded])
回答by periklis
More recently, for version 3+:
最近,对于版本 3+:
var parent = '#';
var node = { id:123,text:"Hello world"};
$('#yourtree').jstree('create_node', parent, node, 'last');
Alternative syntax that seems to be working:
似乎有效的替代语法:
$('#yourtree').jstree().create_node(parent, node, 'last');