最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery Fancy Tree with Local Array Data - Stack Overflow

programmeradmin0浏览0评论

I am trying to implement jQuery FancyTree / with local array data

Referred from /

This is the code. But it is not working, No Script Error.But Tree is empty!!!

Even i copied the jQuery, UI versions of the file they using in a demo site. Still nothing works

<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>

I am trying to implement jQuery FancyTree http://wwwendt.de/tech/fancytree/demo/ with local array data

Referred from https://code.google./p/fancytree/

This is the code. But it is not working, No Script Error.But Tree is empty!!!

Even i copied the jQuery, UI versions of the file they using in a demo site. Still nothing works

<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>
Share Improve this question asked Feb 14, 2013 at 15:16 BillaBilla 5,26623 gold badges66 silver badges108 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

I have noticed that source:[] is how you initializes the tree in $("#tabTree").fancytree() initialization call, so your example would be:

<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>

btw, in case you noticed it, the documentation is quite messy, as they are refactoring the code, the documentation is half what's left from dynatree and the new conventions of fancytree. So expect more weird stuff like that :-)

are the Scriptpath right?

Do you download "jquery.js, jquery-ui.custom.js, ui.fancytree.css and jquery.fancytree.js" ?

发布评论

评论列表(0)

  1. 暂无评论