2
私は.Net Webサービスからデータを取得する 'jsTree'ツリービューを作成しようとしています。 aノードのhref属性を除いて、すべてが機能しています。私が何をしようと、それは常に '#'としてレンダリングされます。 ドキュメントからわかるように、データオブジェクトのすべての属性がaノードにコピーされます。jsTree - Jsonデータのhref属性の設定
以下は私の現在のjsonオブジェクトの例です。とにかくhref属性がノードにコピーされない理由を理解できますか?
[ { "attributes" : { "id" : "rootnode_2",
"rel" : "root2"
},
"children" : [ { "attributes" : { "id" : "childnode_9",
"rel" : "folder"
},
"children" : [ { "attributes" : { "id" : "childnode_23",
"rel" : "folder"
},
"children" : null,
"data" : { "href" : "http://www.google.com",
"title" : "Test_Below_1"
},
"state" : null
} ],
"data" : { "href" : "http://www.google.com",
"title" : "Test_1"
},
"state" : null
},
{ "attributes" : { "id" : "childnode_10",
"rel" : "folder"
},
"children" : [ { "attributes" : { "id" : "childnode_24",
"rel" : "folder"
},
"children" : null,
"data" : { "href" : "http://www.google.com",
"title" : "Test_Below_2"
},
"state" : null
} ],
"data" : { "href" : "http://www.google.com",
"title" : "Test_2"
},
"state" : null
}
],
"data" : { "href" : "http://www.google.com",
"title" : "Glatt"
},
"state" : "closed"
} ]
これは私がツリーを初期化する方法です。
$("#jstreejson").jstree({
json_data : {
"data": treeObject
},
themes: {
"theme": "apple",
"dots": true,
"icons": true,
"url": "/Scripts/themes/apple/style.css"
},
plugins: ['core', 'themes', 'json', "json_data"]
});
に試してみてくださいhrefの値を 'data'ハッシュではなく' attr'ハッシュに加えてください。 – Amir
これは完全に機能しました。ありがとう! – Erik