私はjsonデータ形式を使用してjsTreeを持っています。 ルートノードセットのロードは問題ありません。"jstree" jqueryプラグインを使用して子ノードとしてjson変数を追加する方法 - no ajax
私の問題は、クリックされた親ノードに子ノードを追加する方法です。
助けていただければ幸いです。
ありがとうございます!
$("#tree-cat1")
.bind("open_node.jstree", function (event, data) {
console.log(data.rslt.obj.attr("id"));
//eval(loadChild());
//at this point i need to append the result of loadChild() to the tree under the relevant node
})
.jstree({
"json_data": {
"data": eval(loadRoot())
},
"themes": {"theme": "classic","dots": true,"icons": true},
"plugins": ["themes", "json_data", "ui"]
})
function loadRoot() {
return "[{'data':'A node','state':'closed','attr':{'id':'A'}}]";
}
function loadChild() {
return "[{'data':'A1 node','attr':{'id':'A1'}}]";
}
あなたは子供たちに、ノードが開かれるたびに追加しますか?なぜツリーの初期化時にアイテムを追加するのに 'children'プロパティを使わないのですか? – Irishka
ノードを展開するたびにOracleのクエリーを実行してデータを取得します(すべてがjavascript内にあります)。データはjs変数に戻されます。私は木の関連ポイントで返されたデータをツリーに入れる必要があります(コードサンプルごと) – lance