我是 Jquery 的 Fancytree 插件的新手。
我想延迟加载树的节点。
我无法从不同来源加载这些节点。
两个节点都从同一单一源获取数据。 我希望节点“Lazy Folder1”应该从 example1.json 加载数据 并且节点“Lazy Folder2”应该从sample2.json加载数据
$(function(){
var sampleSource = [
{ title: "Lazy Folder1", lazy: true },
{ title: "Lazy Folder2", lazy: true }
];
$("#tree").fancytree({
source: sampleSource,
lazyLoad: function(event, data) {
data.result = { url: "sample1.json" };
}
});
});
以下是 plunker 的链接:-
最佳答案
解决方案的 Plunker 链接 http://plnkr.co/edit/ZLdgkKUIpg3hinpoYZQK?p=preview
$(function(){
var sampleSource = [
{ title: "Lazy Folder1", lazy: true, key: 1 },
{ title: "Lazy Folder2", lazy: true, key: 2 }
];
$("#tree").fancytree({
source: sampleSource,
lazyLoad: function(event, data) {
var node = data.node;
data.result = {
url: "sample" + node.key.toString() + ".json",
data: { mode: "children", parent: node.key },
cache: false
};
}
});
});
这会帮助别人...
关于JQuery FancyTree 节点的多个延迟加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43834268/