Search code examples
javascriptjqueryjstree

How do I bind a callback function on the complete jstree reload event?


I have a button that reloads (resends an AJAX request) the jsTree once is clicked.

Here is a sample configuration code I have:

treeContainer.bind("loaded.jstree", function () {
    alert("the tree is loaded");
}).jstree(config);

The problem I experience is that I do not have the alert (wrapped in a callback function) displayed once the 'reload' button is clicked the 2nd, 3rd, etc. times. Am I using the wrong jstree status event?

To summarize, I want a jsTree callback function to be executed each time I click the 'reload' button.

I am currently using jsTree 1.0-rc1 (rev. 191).


Solution

  • I know it's an old question, but I ran into the same problem with jsTree 3.3.4. Solution that works is:

    treeContainer.bind("refresh.jstree", function (event, data) {
        alert("the tree has been refreshed");
        $(this).jstree("open_all");  //Example: open all nodes after refreshing
    })