我正在尝试在我的一个项目中使用这个jQuery插件(jsTree)。
我发现的其他所有内容最近都没有更新过。
无论如何,我正在使用这个插件来加载一个文件夹结构,但是我想异步执行这个操作。我在他们的网站(叫做async)上找到的例子是荒谬的。我试着在网上查过,但似乎大多数人都下载了整棵树。我想在每次单击节点时加载一个分支。我使用的是JSON。
提前感谢
发布于 2010-03-12 02:49:05
我目前在jQuery 1.4中的jsTree中使用了这个,这里有一个例子,它是非常未压缩的,以使它更清晰:
$("#QuickNav").tree({
data: {
async: true,
type: "json",
opts: {
method: "POST",
url: rootPath + "QuickNav"
}
},
callback: {
beforedata: function(NODE, TREE_OBJ) {
return $(NODE).attr("id") === "" ?
{ id: $(NODE).find("a:first").attr("id")} :
{ id: $(NODE).attr("id") || 0 };
},
onchange: function(NODE) {
document.location.href = $(NODE).children("a:first").attr("href");
}
}
});我从该Url返回的JSON示例:
[{
"data": {
"title": "Title (<b link='/Thing/200' class='gtp'>Go to Page</b>)",
"attributes": {
"href": "#",
"id": "200"
}
},
"state": "closed"
}]这里的id是唯一传递给我的web服务方法回调的东西,导致JSON像这样被返回:
[{
"data": {
"title": "Sites",
"attributes": {
"href": "#",
"class": "TreeTitle"
}
},
"state": "open",
"children": [
{
"data": {
"title": "00001 - Test Thing",
"type": "link",
"attributes": {
"href": "/Site/39063",
"class": "TL"
}
}
},
{
"data": {
"title": "00002 - Test Thing 2",
"type": "link",
"attributes": {
"href": "/Site/39069",
"class": "TL"
}
}
}
]
}]https://stackoverflow.com/questions/2427039
复制相似问题