У меня есть экземпляр Jstree.Это AJAX с JSON.
Вот как я создаю дерево.
$("#tree").jstree({
"plugins" : ["themes", "json_data", "ui"],
"json_data" : {
"ajax" : {
"type": 'GET',
"url": function (node) {
var nodeId = "";
var url = ""
if (node == -1)
{
//first url called is static
url = "myUrl";
}
else
{
//click on a node "li", get the id, append it to the url.
nodeId = node.attr('id');
url = "myUrl" + nodeId;
}
return url;
},
"success": function (new_data) {
//get the data topNode out of the json object
new_data = new_data.topNode;
return new_data;
}
}
},
});
Вот вывод.
<div id="tree" class="jstree-classic jstree jstree-0 jstree-focused jstree-default">
<ul>
<li class="jstree-closed jstree-last">
<ins class="jstree-icon"> </ins>
<a class="" href="#">Item 1</a>
</li>
</ul>
</div>
Однако, когда дерево отображаетсяэлемент
не имеет идентификатора.Должен автоматически добавляться к .Чего мне не хватает?