Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Shilpi on Aug 18, 2008 11:39
open dhtmlx forum
dhtmlxMenu usbmenu caption

I am using the following XML to set a menu:
<?xml version='1.0' encoding='iso-8859-1'?>
<menu name="" width="100%" height="30" withoutImages="1" mixedImages="0">
    <MenuItem name="Menu1" id="menu1_id">
    </MenuItem>
    <MenuItem name="Menu2" id="menu2_id">
    </MenuItem>
    <MenuItem name="Help" id="help_id" mode="popup" withoutImages="1">
        <MenuItem name="Help1" id="help1_id" />
        <MenuItem name="Help2" id="help2_id" />
        <divider id="div_1"/>
        <MenuItem name="About" id="about_id" />
    </MenuItem>    
</menu>

My question is how can I change the caption of a submenu say 'Help1' which is under the menu 'Help'. I tried the following:
var item = amenubar.getItem("help1_id");
item.setText("Help111");

It gives a javascript runtime error.
Answer posted by Support on Aug 19, 2008 02:12
The code which you are using is correct,  please be sure that menu already loaded from XML , on moment of command call.
Data loading is async, so calling such command exactly after loadXML command - will not work
The next code can be used

amenubar.loadXML(url,function(){
   // this code will be executed only after data loading
    var item = amenubar.getItem("help1_id");
    item.setText("Help111");
});