Home API Docs Linkr LinkrTree Class

LinkrTree Class - Template methods

Attention: open in a new window.PDFPrintEmail
Article Index
LinkrTree Class
Object options
Search settings
Template methods
All Pages

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 External 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
NOTE: all template methods can be overriden with your own custom functions.

Linkr 2.3.7 (20 May 2010) is finally out. This release tackles many bugs and will make the overall usage a little smoother.