, , json. jstree , html jstree.
node -, .
javascript
<a href="javascript: selectLeftNavNode(339);">Edit</a>
339 - ,
,
function selectLeftNavNode(node) {
$('#demo').jstree('deselect_all');
$('#demo').jstree('select_node', '#node_' + node);
}
, , , , ,
ajax , id
, ajax - xml
<?xml version="1.0" encoding="UTF-8"?>
<response>
<paths>
<path>339</path>
<path>338</path>
<path>38</path>
</paths>
</response>
function selectLeftNavNode(node) {
$('#demo').jstree('deselect_all');
if($('#demo').jstree('select_node', '#node_' + node) === false)
{
$.ajax({
type: "POST",
dataType: "xml",
url: your_url_to_php_script',
data: {node_id:node},
success: function(data)
{
var remaining_nodes = new Array();
var paths_count = $(data).find('response').find('path').length;
for(var x=1;x<=paths_count;x++){
remaining_nodes[x-1] = $(data).find('response').find('paths path:nth-child('+x+')').text();
}
open_nodes_step_by_step(remaining_nodes);
}
});
}
}
, , open_node, node node, , node, select_node
function open_nodes_step_by_step(remaining_nodes)
{
var nodes = remaining_nodes.slice();
tree = jQuery.jstree._focused();
if(nodes.length > 1){
var nodes_left = remaining_nodes.slice();
nodes_left.pop();
var to_open = nodes.length - 1;
tree.open_node(document.getElementById('node_' + nodes[to_open]), function () {
open_nodes_step_by_step(nodes_left);
});
}
else{
tree.select_node('#node_' + nodes[0]);
}
}
I tested my solution with IE8, FF and Chrome, it seems to work very well, besides, I use jQuery v1.10.1 and jsTree 1.0-rc1 (unfortunately, since the code has been there for many years, and this has this whole database and other integration solutions that I decided not to change to newer versions, it works)
hope i helped someone
Tom