javascriptjqueryjstree

What event is triggered when an arrow or other icon is clicked to expand a branch of a tree?


I know how to trap clicking on a node:

    // Define action when a node was clicked.
    $('#mytree').on("select_node.jstree", function (e, data) {
      // do whatever
    });

But I can't figure out which event is triggered when clicking an icon to expand a branch of a tree. I have reviewed the list of events in the documentation, but none stands out as self-evident. I tried:

// Define action when a node is expanded.
$('#mytree').on("select_node.jstree", function (e, data) {
    // do whatever
});

but it didn't get triggered. I also tried:

// Define action when a node is expanded.
$('#mytree').on("open_node.jstree", function (e, data) {
    /do whatever
});

but that gets triggered for each node when the tree is loaded, not when a specific node is clicked to expose its children.


Solution

  • I couldn't add this as comment, have u tried click.jstree ?

    $('#mytree').on("click.jstree", function (e, data) {
        //do something
    });