tree.js

Converts <ul> into interactive tree.


Objects

Methods


OAT.Tree(optionsObject)

optionsObject may contain any of the following:

OAT::Tree::assign(listElement, collapse)

This converts a list into an interactive tree. listElement specifies an <ul> element in which your list lives. Argument collapse toggles initial collapsing of whole tree.

Tree data structure can be accessed and modified. See following simple examples for usage:

var t1 = new OAT.Tree({imagePath:"images",imagePrefix:"",ext:"gif"}); // will take images from images/Tree_*.gif
var t2 = new OAT.Tree({imagePath:"images",imagePrefix:"prefix",ext:"png"}); // will take images from images/Tree_prefix_*.png
t1.assign("myUL1", true); // collapsed
t2.assign("myUL2", false); // expanded

var node1 = t1.tree.children[0];
var node2 = t2.tree.children[1];

node2.appendChild(node1);
node1.setLabel("newLabel");
node2.expand();
node1.createChild("newLabel", true); // second argument means that new child is a node rather than leaf
node2.deleteChild(node1);