現在、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"
}
}
}
]
}]