Categories | Question details Back To List | ||
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" ?> <menu absolutePosition="auto" mode="popup" width="100%" withoutImages="yes"> <MenuItem name="test" id="1" withoutImages="yes"> </MenuItem> </menu> 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(); Answer posted by Support on May 15, 2008 07:32 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 ( The item which has not child, has not ready to use sub-menu panel, so it need to be created first ) Answer posted by Cyril on May 15, 2008 11:11 Thank you for the quick response. I will still use the getPanel but with a useless <divider id="div_1" /> (with a CSS http://www.google.com/search?hl=en&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=modification+for+hiding+it&spell=1">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> |