4

我正在尝试使用本地数组数据实现 jQuery FancyTree http://wwwendt.de/tech/fancytree/demo/

引用自https://code.google.com/p/fancytree/

这是代码。但它不起作用,没有脚本错误。但是树是空的!!!

即使我复制了他们在演示站点中使用的文件的 jQuery、UI 版本。仍然没有任何效果

<html>
<head>
    <script src="jquery.js" type="text/javascript"></script>
    <script src="jquery-ui.custom.js" type="text/javascript"></script>
    <link href="ui.fancytree.css" rel="stylesheet" type="text/css" />
    <script src="jquery.fancytree.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#tree").fancytree({
                onActivate: function (node) {
                    // A DynaTreeNode object is passed to the activation handler

                    // Note: we also get this event, if persistence is on, and the 
                     //  age is reloaded.
                    alert("You activated " + node.data.title);
                },

                children: [ // Pass an array of nodes.
                {title: "Item 1" },
                { title: "Folder 2", isFolder: true,
                    children: [
                        { title: "Sub-item 2.1" },
                        { title: "Sub-item 2.2" }
                    ]
                },
                { title: "Item 3" }
            ]
            });
        });

    </script>
</head>
<body>
    <div id="tree">
    </div>
</body>
</html>
4

2 回答 2

4

我注意到这source:[]是你在$("#tabTree").fancytree()初始化调用中初始化树的方式,所以你的例子是:

<html>
<head>
    <script src="jquery.js" type="text/javascript"></script>
    <script src="jquery-ui.custom.js" type="text/javascript"></script>
    <link href="ui.fancytree.css" rel="stylesheet" type="text/css" />
    <script src="jquery.fancytree.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#tree").fancytree({
                onActivate: function (node) {
                    // A DynaTreeNode object is passed to the activation handler

                    // Note: we also get this event, if persistence is on, and the 
                     //  age is reloaded.
                    alert("You activated " + node.data.title);
                },
                source: [ // Pass an array of nodes.
                {title: "Item 1" },
                { title: "Folder 2", isFolder: true,
                    children: [
                        { title: "Sub-item 2.1" },
                        { title: "Sub-item 2.2" }
                    ]
                },
                { title: "Item 3" }
            ]
            });
        });

    </script>
</head>
<body>
    <div id="tree">
    </div>
</body>
</html>

顺便说一句,如果您注意到它,文档非常混乱,因为他们正在重构代码,文档是 dynatree 和 fancytree 的新约定剩下的一半。所以期待更多这样奇怪的东西:-)

于 2013-02-20T23:08:50.583 回答
-1

脚本路径对吗?

你下载“jquery.js、jquery-ui.custom.js、ui.fancytree.css 和 jquery.fancytree.js”吗?

于 2013-02-14T15:35:09.217 回答