Fancytree - Init from object array
This sample includes all options (with their default values) to allow playing with them.
by Stéphane Cabaret
HTML
<link rel="stylesheet" href="https://rawgithub.com/mar10/fancytree/master/src/skin-win8/ui.fancytree.css">
<script src="https://rawgithub.com/mar10/fancytree/master/src/jquery.fancytree.js"></script>
<div id="tree"></div>
<div id="statusLine">-</div>
<p>
<button id="button1">Select item2</button>
</p>
JavaScript
$(function(){
$("#tree").fancytree({
checkbox: true,
source: [
{title: "Node 1"},
{title: "Node 2", key: "id2"},
{title: "Folder 3", folder: true, children: [
{title: "Node 3.1"},
{title: "Node 3.2"}
]},
{title: "Folder 2", folder: true}
],
activate: function(event, data){
$("#statusLine").text("Active node: " + data.node);
}
});
// Activate a node, on button click
$("#button1").click(function(){
var tree = $("#tree").fancytree("getTree"),
node2 = tree.getNodeByKey("id2");
node2.toggleSelected();
});
$("span.fancytree-node:").hover( function () {
$(this).css({"background-color":"#eff9fe"});
},
function () {
$(this).css({"background-color":"white"});
}
//alert('adf')
)
});