我有一些代碼需要將子節點添加到本身包含子節點的jstree中。下面的代碼將'child2'節點正確添加到'child1',但忽略了child3數據。任何幫助非常感謝。代碼如下: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", "attr" : { "id" : "child2.id" },
"children" : [ { "data" : "child3", "attr" : { "id" : "child3.id" }, "children": [ ] } ] },
function() { alert("added"); }, true);
});
});
</script>
</head>
<body>
<div id="tree" name="tree"></div>
<input type="button" id="add" value="add" />
</body>
</html>
也許這並不可能?我想presuemd創建函數實施,以緩解兒童,但也許不是......去看看來源... – user419766 2010-08-16 20:01:17
我有同樣的問題你怎麼能解決它? – 2013-08-12 22:01:47