nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / jqTree / static / examples / custom_html.js
1 $(function() {
2     var $tree = $('#tree1');
3
4     $tree.tree({
5         data: ExampleData.example_data,
6         autoOpen: 1,
7         onCreateLi: function(node, $li) {
8             // Append a link to the jqtree-element div.
9             // The link has an url '#node-[id]' and a data property 'node-id'.
10             $li.find('.jqtree-element').append(
11                 '<a href="#node-'+ node.id +'" class="edit" data-node-id="'+ node.id +'">edit</a>'
12             );
13         }
14     });
15
16     // Handle a click on the edit link
17     $tree.on(
18         'click', '.edit',
19         function(e) {
20             // Get the id from the 'node-id' data property
21             var node_id = $(e.target).data('node-id');
22
23             // Get the node from the tree
24             var node = $tree.tree('getNodeById', node_id);
25
26             if (node) {
27                 // Display the node name
28                 alert(node.name);
29             }
30         }
31     );
32 });