Rendering the GUI

The Tree object is the powerhouse in this component because it parses the response data that is received from the TreeManager object and creates a tree structure that is later appended to an HTML element or the HTML document body by TreeManager. In other words, this object pretty much does it all. The object is a prototype, which means it can be instantiated, and contains a constructor function. Listing 11.5 shows the code snippet for this constructor.

Listing 11.5. Constructing a tree Object (Tree.js)
function Tree(data)
{
    this.data = data;
    this.childArray = new Array();
    this.tree = '';
}

The tree object’s constructor takes a data parameter, which is the response data from TreeManager, and sets the data to a local property ...

Get Ajax for Web Application Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.