summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE/client/bower_components/jqTree/_entries/63_tree-click.md
blob: acd430dc3b3f4b3bf5466f19ac05d4af4dae0a2e (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
28
29
30
31
32
33
34
35
36
37
---
title: tree.click
name: event-tree-click
---

Triggered when a tree node is clicked. The event contains the following properties:

* **node**: the node that is clicked on
* **click_event**: the original click event

{% highlight js %}
// create tree
$('#tree1').tree({
    data: data
});

// bind 'tree.click' event
$('#tree1').bind(
    'tree.click',
    function(event) {
        // The clicked node is 'event.node'
        var node = event.node;
        alert(node.name);
    }
);
{% endhighlight %}

The default action is to select the node. You can prevent the selection by calling **preventDefault**:

{% highlight js %}
$('#tree1').bind(
    'tree.click',
    function(event) {
        event.preventDefault();
    }
);
{% endhighlight %}