I am using jsTree 3.0.9. I made a screencast to help illustrate the problem:
https://www.youtube.com/watch?v=tZLVS1a2f1M&feature=youtu.beHere are the steps that produce it.
1.) On the initial load of the tree I run "getNodeAndChildren". This loads the root node of the tree and its children to a depth of 1. The video shows this step already complete from 0:00 to 0:10. This is just the default presentation of the tree. The user can browse the tree and the nodes will be expanded and jstree will load them correctly. Everything is fine here. Note that the root node does not have an id associated with it, so jstree assigned the id of "j1_1". All of the children have numeric ids that were sent from the server. This is because there is no real ICD9 root node, and the root node is just there to hold the tree together.
2.) If the user does not want the default state of the tree they can search the tree. The results are returned as a full tree of filtered nodes (not just a depth of 1). This occurs @0:12. Searching the tree provides matches. In this step, everything is still ok. The functionality works great and jstree handles loading the nodes correctly.
3.) @0:32 The user clicks the "twiddle" button. This is a button I have added to each non-leaf node. When the user clicks the "twiddle" button, a request is sent to the server to get all of the children for this node regardless of the search. So for instance after searching the tree, the user decides that they want to see all of the children for a particular node, (and not just the search results), they can click the twiddle button. The twiddle button click initiates a refresh_node on the node and sends a "getChildren" request to the server.
4.) The twiddle button works correctly for me in every case except when performed on the root node. Because I have let jstree apply the id of the root node, it gives the node an id of "j1_1" however the server is looking for only numeric values for the node id. The server returns an HTTP 500 for java.lang.NumberFormatException. That is easy to fix/prevent, but it is not the server side I am worried about. After this call to "getChildren" on the root node jstree initiates an infinite loop requesting getChildren over and over again, and the server keeps sending the 500 error code.
Here is a video of the twiddle button and getChildren call working successfully. Its main purpose is to ask the server for all of the children of a node, and not just the ones that came back as matched from the initial search. It works on every node but the root node.
https://www.youtube.com/watch?v=npV8N9YvEfQ&feature=youtu.beThanks for the help!