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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.