Mixed initialization

Hi,



I trying to work the dhtmlxmenu in Mixed initialization. I want to add a child to a node. When the node is empty I have the error :

error: ‘items’ is null or not an object.

But when the node have at least one child it works fine.



Here my code :



XML

---------------------------

<?xml version="1.0" ?>











Javascript

--------------------------

function CreateDynamic(){

var subMenu = aMenuBar.getPanel(“1”);

var item = new dhtmlXMenuItemObject(“1.1”,“testchild”,null,null,"");

aMenuBar.addItem(subMenu,item);

}

aMenuBar=new dhtmlXMenuBarObject(document.getElementById(‘MenuMutualFunds’),‘100%’,‘100%’,’’);

aMenuBar.setGfxPath(“dhtmlx/menu/imgs/”);

aMenuBar.loadXML(“dhtmlx/menu/_menu.xml”,CreateDynamic);



//show menu

aMenuBar.showBar();






If you want to add the child menu item to existin one, you need to create a sub-menu panel as first step



var subMenu = new   dhtmlXMenuBarPanelObject(menu,“1”,false,120,true);  // instead of getPanel
var subItem = new dhtmlXMenuItemObject(“10001”,“HSBC”,null,null,“menuButtonSecond”);
aMenuBar.addItem(subMenu,subItem);



( The item which has not child, has not ready to use sub-menu panel, so it need to be created first )


Thank you for the quick response.



I will still use the getPanel but with a useless <divider id=“div_1” /> (with a CSS modification for hiding it ) in my MenuItem because I don’t need the sub-menu panel



<MenuItem name=“Update” id=“1” src=“bullet.gif”>



    <divider id=“div_1” />



</MenuItem>