How can I modify ajax response before jsTree creation? I would like to access each node ID and add prefix to it. On jsTree page the only clue is this: the function will receive two arguments – the node being loaded & a function”. I need to do that before the tree is actually created, to avoid duplicate ID in the document.
"json_data" : {
"ajax" : {
"type": "GET",
"url" : "tree.json"
},
"data" : function(node, func){
//how to use that?
}}
I have expected to get JSON data here, modify it and return? But this will explode.
I have successfully manipulated data using the success callback in the instantiation of the jsTree. In my case, I am parsing XML data returned as JSON from a .NET webmethod. It should work for your case in a similar manner.
Another method is to use the “complete” callback function to manipulate the jsTree in its final form. I don’t recommend it in your case of duplicate id’s, however.