Attaching to existing Layout

I have a page that is calling onInit() in a separate .js file. onInit() creates a Layout that contains a Tabbar. The first tab of that tabbar makes an ajax call to load a tree. When an element of the tree is selected I need to take action on one of the original Layout object’s cells.



However, I cannot create a var that properly attaches to the original layout object. If I use the “new dhtmlXLayoutObject” it just creates a second Layout, I want to attach to the original one. Here are the two methods:



function onInit()

{

var dhxLayout = new dhtmlXLayoutObject(“dhParentID”, “3L”);

var dhxTabbar = dhxLayout.cells(“a”).attachTabbar();

dhxTabbar.addTab(“a1”,“Results”,“100px”);

dhxTabbar.addTab(“a2”,“Search”,“100px”);

dhxTabbar.setHrefMode(“ajax”);

dhxTabbar.setContentHref(“a1”,“ResultsFormer.aspx?mode=xload”);

dhxTabbar.setTabActive(“a1”,true);

}



function onResultTreeNodeSelect(nodeId)

{

var dhxLayout = new dhtmlXLayoutObject(“dhParentID”);



dhxLayout.cells(“b”).attachURL(“UserLoad.aspx?BaseNode=” + nodeId);

}


Possibly the following…


function onInit()
{
var dhxLayout = new dhtmlXLayoutObject(“dhParentID”, “3L”);
var dhxTabbar = dhxLayout.cells(“a”).attachTabbar();
dhxTabbar.addTab(“a1”,“Results”,“100px”);
dhxTabbar.addTab(“a2”,“Search”,“100px”);
dhxTabbar.setHrefMode(“ajax”);
dhxTabbar.setContentHref(“a1”,“ResultsFormer.aspx?mode=xload”);
dhxTabbar.setTabActive(“a1”,true);


return dhxLayout ;
}


var layout = onInit();


layout.cells(“b”).attachURL(“UserLoad.aspx?BaseNode=” + nodeId);