Example 8 - multiple select

This example implements multiple select using the following functions and events:

html

<div id="tree1" data-url="/nodes/"></div>

javascript

var $tree = $('#tree1');

$tree.tree({
    data: ExampleData.exampleData,
    autoOpen: true
});

$tree.on( 'tree.click', function(e) {
    // Disable single selection
    e.preventDefault();
    var selected_node = e.node;

    if (selected_node.id === undefined) {
        console.warn('The multiple selection functions require that nodes have an id');
    }

    if ($tree.tree('isNodeSelected', selected_node)) {
        $tree.tree('removeFromSelection', selected_node);
    } else {
        $tree.tree('addToSelection', selected_node);
    }
});