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">show/hide connectors</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() {
$(".fancytree-container").toggleClass("fancytree-connectors");
});
});