Renaming menu items

Forums » General discussion
     » Renaming menu items

2008/05/23 17:19

I'd like to dynamically change the label of a menu item. The documentation for DlMenuItem states:

label (label, force)

ArgumentsNotesType
Default
labelNew label[String]optionalnull
forceForce new label?[boolean]optionalfalse

Returns or changes the label of the button. If you pass no arguments, the existing label is returned. If you pass label, then a new label is set for the button and “onUpdateLabel” is triggered, but only if the new label is different from the existing label, or if force is true.

However, attempting to use this code:

var item = new DlMenuItem({
        parent: menu, 
        label: "Rename me" 
});

...

item.label("New name");

Gives me the error "item.label is not a function". Looking at the code with Firebug confirms, label is simply a property (and that it's a DlMenuItem object that i'm looking at). Attempting to set that property with:

 item.label = "New name"; 

changes the internal property but not what's displayed on screen. Is the documentation wrong?

EDIT

Turns out I don't need this one urgently. But I am still curious.


2008/05/24 13:15

Oh, it looks like I missed to add this method...  For now you can use setContent instead (note that it won't update the item.label property though):

item.setContent("new_label");

DynarchLIB.com
all hands person