gpt4 book ai didi

javascript - 带有本地数组数据的 jQuery Fancy Tree

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:03:45 25 4
gpt4 key购买 nike

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

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

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

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>

最佳答案

我注意到 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 的新约定剩下的一半。所以期待更多像这样的奇怪的东西:-)

关于javascript - 带有本地数组数据的 jQuery Fancy Tree,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14877996/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com