Page 4 of 4
Template methods
The template methods are essentially helper functions. At the very least, a method setupTree must be defined that will return a list of tree items:var tmplMethods =
{
setupTree : function(array, level)
{
// Tree items
var tree = {};
// Setup tree items
array.each(function(item)
{
// Each item has a title, description, URL,
// tree level, expandIcon, collapseIcon,
// and children value. Children is an array
// containing the search type and the search query.
var treeItem =
{
title : 'Test',
level : level, // Item level in tree
children : ['item', 'query']
};
// Each item needs an reference ID
var ref = 'reference-id';
// The item ID is used as a key
// in the tree reference
tree[ref] = treeItem;
});
// Return formatted tree items
return tree;
}
};
For documenation on the use of each (on arrays), follow this link
.Other methods that are defined by default include:
- buildTree: builds the visual tree for display
- toggle: toggles a tree item
- expand: expands a tree item
- collapse: collapses a tree item
- children: builds the visual tree for a tree item



