小编use*_*766的帖子

以编程方式将子节点添加到jstree

我正在尝试编写一些动态地将节点添加到jstree的代码.我已经按照http://www.jstree.com/documentation/crrm上的文档进行了操作,但无法得到一个简单的示例 - 正在添加节点child2,但它正被添加到节点的root中. id'而不是'child1.id'指定...任何提示将不胜感激.代码如下

<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" …
Run Code Online (Sandbox Code Playgroud)

javascript jstree

13
推荐指数
1
解决办法
3万
查看次数

jstree - 添加自己包含子节点的子节点

我有一些代码,我需要能够将子节点添加到jstree本身包含子节点.下面的代码正确地将'child2'节点添加到'child1'但忽略了child3数据.任何帮助非常感谢.代码如下:

<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" : …
Run Code Online (Sandbox Code Playgroud)

javascript jquery jstree

6
推荐指数
1
解决办法
4549
查看次数

标签 统计

javascript ×2

jstree ×2

jquery ×1