我正在尝试编写一些动态地将节点添加到jstree的代码。我按照文档http://www.jstree.com/documentation/crrm,但不能得到一个简单的例子工作 - 节点child2被添加,但它被添加到节点'root.id'而不是'child1.id'指定。 ..任何提示将不胜感激。代码如下以编程方式将子节点添加到jstree
<html>
<head>
<script type="text/javascript" src="http://static.jstree.com/v.1.0rc2/jquery.js"></script>
<script type="text/javascript" src="http://static.jstree.com/v.1.0rc2/jquery.jstree.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(function() {
$("#tree").jstree({
"json_data" : {
"data" : [
{
"data" : "parent",
"attr" : { "id" : "root.id" },
"children" : [ { "data" : "child1",
"attr" : { "id" : "child1.id" },
"children" : [ ] }
]
},
]
},
"plugins" : [ "themes", "json_data", "crrm" ]
});
});
$("#add").click(function() {
$("#tree").jstree("create", $("#child1.id"), "inside", { "data" : "child2" },
function() { alert("added"); }, true);
});
});
</script>
</head>
<body>
<div id="tree" name="tree"></div>
<input type="button" id="add" value="add" />
</body>
</html>
对我来说,“创建”操作不起作用......我sp明确的“create_node”,它的工作! – 2011-04-14 14:53:09
对于它的价值,我无法让'创造'工作。虽然'create_node'确实起作用,我认为参数必须不同。如果他们的文档没有那么无用,那肯定会很好。你知道我在哪里可以找到'create_node'方法的文档吗? – Brad 2011-07-13 00:54:12
http://www.jstree.com/documentation 转至核心文档超链接 – Ashwin 2012-04-20 11:34:14