Categories | Question details Back To List | ||
Loop through Menu items Thanks for your prompt reply, however it didn't seem to work. I am using the code below: aMenuBar=new dhtmlXMenuBarObject(document.getElementById('xpstyle'),'100%',22,''); aMenuBar.setOnClickHandler(onButtonClick); aMenuBar.setGfxPath('./include/Menu/img/'); aMenuBar.loadXML('./include/Menu/_menu.xml'); aMenuBar.showBar(); children = aMenuBar.getPanel('booking_action').items; aMenuBar.hideItem(children[1].id) The _menu.xml contains: <?xml version='1.0' ?> <menu maxItems="12" name="" mixedImages="yes"> <MenuItem name="Action" src="Eng.png" imageSize="24" id="booking_action" disableImage="no" withoutImages="yes" > <MenuItem name="Unbook" id="btn_Unbook"/> <MenuItem name="Terminate" id="btn_Terminate"/> <MenuItem name="Extend" id="btn_Extend"/> <MenuItem name="Temp to Perm" id="btn_TemptoPerm"/> <MenuItem name="Delete" id="btn_Delete"/> </MenuItem> </menu> And when I run the script I get the error: children[1] has no properties Any Ideas Answer posted on May 14, 2008 07:30 The code is correct problem caused by the timing. The loading of XML is async., so you need to catch moment when data loaded , it can be done as aMenuBar.showBar(); aMenuBar.loadXML('./include/Menu/_menu.xml',function(){ // code here will be called only after xml loading children = aMenuBar.getPanel('booking_action').items; aMenuBar.hideItem(children[1].id) }); |