<div id="example" class="hx-tree">
<div class="hx-tree-node">
<div class="hx-tree-node-parent"><div class="hx-tree-node-content">Parent 1</div></div>
<div class="hx-tree-node-children" style="display:none">
<div class="hx-tree-node">
<div class="hx-tree-node-content">Item 1</div>
</div>
<div class="hx-tree-node">
<div class="hx-tree-node-parent"><div class="hx-tree-node-content">Parent 2</div></div>
<div class="hx-tree-node-children" style="display:none">
<div class="hx-tree-node">
<div class="hx-tree-node-content">Item 2</div>
</div>
</div>
</div>
</div>
</div>
</div>
var tree = new hx.Tree('#example')
<div id="example-dynamic"></div>
var tree = new hx.Tree('#example-dynamic', {
renderer: function (elem, data) { hx.select(elem).html(data.name) },
items: [
{
name: 'Parent 1',
children: [
{
name: 'Item 1'
},
{
name: 'Parent 2',
children: [
{
name: 'Item 2'
}
]
}
]
}
]
})
var renderer = function(element, datum) {
element.innerHTML = datum.name
element.style.color = datum.color || 'black'
}
var renderer = function(element, datum) {
element.innerHTML = datum.name
element.style.color = datum.color || 'black'
}
items
method, these classes will be added to content automatically. hx-tree
or hx-tree-node-children
elements. hx-tree-node
and after a hx-tree-node-parent
element. hx-tree-node
that doesn't include hx-tree-node-parent
or hx-tree-node-children
. hx-tree-node
and before a hx-tree-node-children
element. hx-tree-node-parent
element.