I have a jstree object that I use to store data, and I use ajax to complete it after the step. I call the ajax.php file, which will return the nodes formatted in HTML, depending on the data that I send to it.
My problem is this: I know that the data that I receive already contains the structure of the current node, and instead of replacing the current node with the data that it receives from the ajax call, jstree adds the structure to the current nodes as a new son, which I donβt want.
For example, if I click on node 1:
0 | - 1 | - 2
I will get the following structure:
0 | - 1 | | - 1 | | | - 1.1 | | | - 1.2 | - 2
I cannot change the return of the ajax call, however, I thought that it would be possible to reduce the bit to the following code in order to replace the node with the returned data instead of inserting it as a child node of the current node:
$node.jstree({ "plugins" : [ "themes", "html_data" ], "html_data" : { ajax: { url: "ajax.php", data: function(node){ return { index: (node != -1) ? node.attr("id") : 0 }; }, type: "POST" } }, animated: 'fast' });
Thanks so much for your answers :)
source share