summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE/client/bower_components/jqTree/static/examples/multiple_select.js
blob: 54ab18f3234b154d4f75127832f3430c122fa10d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$(function() {
    var $tree = $('#tree1');
    $tree.tree({
        data: ExampleData.example_data,
        autoOpen: true
    });
    $tree.bind(
        'tree.click',
        function(e) {
            // Disable single selection
            e.preventDefault();

            var selected_node = e.node;

            if (selected_node.id == undefined) {
                console.log('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);
            }
        }
    );
});