Hi all,
I am using jsTree to map a directory structure on a Windows machine and am using node.js on that machine to return the JSON document in alternative format. I am trying to use the dynamic update of data through AJAX to avoid having to build the entire tree from the beginning, which can take a couple of minutes in some cases. However I struggling to get this to work and I hope someone can help me out.
The problem is that after jsTree retrieves the initial JSON doc (in Chrome) it gives me this (latest jsTree source from GitHub):
$('#jstree').jstree({ 'core' : {
'multiple' : false,
'data' : {
'url' : function (node) {
nodejs_agent_url+'/dirtree?root_path='+encodeURIComponent(device_path)+'&device='+encodeURIComponent(device_name)+'&type='+device_type :
nodejs_agent_url+'/dirtree?root_path='+encodeURIComponent(
node.id)+'&device='+encodeURIComponent(device_name)+'&type='+device_type;
},
'data' : function (node) { return { 'id' :
node.id }; }
}
}
});
This is an example of data that is returned by the node.js agent that runs on the Windows machine in alternative format:
[
{
"id": "C:\\Users\\joni\\Desktop",
"parent": "#",
"text": "Desktop",
"state": { "opened": true, "selected": false, "disabled": false },
"children": false
},
{
"id": "C:\\Users\\joni\\Desktop\\Private",
"parent": "C:\\Users\\joni\\Desktop",
"text": "Private",
"state": { "opened": false, "selected": false, "disabled": false },
"children": true
}
]
What am I doing wrong? I would be grateful for your insights.
Thanks!
Jonathan