nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / jqTree / _entries / 38_appendnode.md
1 ---
2 title: appendNode
3 name: functions-appendnode
4 ---
5
6 **function appendNode(new_node_info, parent_node);**
7
8 Add a node to this parent node. If **parent_node** is empty, then the new node becomes a root node.
9
10 {% highlight js %}
11 var parent_node = $tree.tree('getNodeById', 123);
12
13 $tree.tree(
14     'appendNode',
15     {
16         name: 'new_node',
17         id: 456
18     },
19     parent_node
20 );
21 {% endhighlight %}
22
23 To add a root node, leave *parent_node* empty:
24
25 {% highlight js %}
26 $tree.tree(
27     'appendNode',
28     {
29         name: 'new_node',
30         id: 456
31     }
32 );
33 {% endhighlight %}
34
35 It's also possible to append a subtree:
36
37 {% highlight js %}
38 $tree.tree(
39     'appendNode',
40     {
41         name: 'new_node',
42         id: 456,
43         children: [
44             { name: 'child1', id: 457 },
45             { name: 'child2', id: 458 }
46         ]
47     },
48     parent_node
49 );
50 {% endhighlight %}