Categories | Question details Back To List | ||
dhtmlXMenu getItem not working Hi, I want to change text of an item after loading an XML menu but getItem is returning undefined. What is wrong here ? My itemID is OK. Thanks, Jean-Michel Here is the code: function createMenu(id, lang, custom){ aMenuBar=new dhtmlXMenuBarObject(document.getElementById('menu_zone'),'100%',16,""); aMenuBar.setOnClickHandler(onButtonClick); aMenuBar.loadXML("./textes/" + lang + "/menu.xml") aMenuBar.enableWindowOpenMode(false); aMenuBar.disableSmartPositioning(true); var item=aMenuBar.getItem("1custom") item.setText(custom); aMenuBar.showBar(); } Answer posted by Stanislav on Jan 04, 2008 05:42 loadXML is async command, which means command next to it will be executed when data not fully loaded yet you need to catch the moment when data loaded, to made any updates to it, it may be done in next way aMenuBar=new dhtmlXMenuBarObject(document.getElementById('menu_zone'),'100%',16,""); aMenuBar.setOnClickHandler(onButtonClick); aMenuBar.enableWindowOpenMode(false); aMenuBar.disableSmartPositioning(true); aMenuBar.loadXML("./textes/" + lang + "/menu.xml",function(){ //code here, will be executed only after data fully loaded var item=aMenuBar.getItem("1custom") item.setText(custom); }) aMenuBar.showBar(); |