meardon - The reason that oFieldContextMenu.getItem(0) is returning undefined is because you have specified that the content of the ContextMenu instance be

Message 2 of 2
, Dec 9, 2008

"meardon" -

The reason that "oFieldContextMenu.getItem(0)" is returning undefined is because you have specified that the content of the ContextMenu instance be lazy loaded:

var oFieldContextMenu = new YAHOO.widget.ContextMenu(

"fieldcontextmenu",

{

trigger: "mainview",

itemdata: oFieldContextMenuItemData,

lazyload: true,// YOU ARE USING LAZYLOAD

effect: { effect:YAHOO.widget.ContainerEffect.FADE, duration:0.25 }

}

);

When you set the "lazyload" configuration property to "true" none of the MenuItems are created until the ContextMenu is initially rendered - which occurs the first time it is requested via the firing of the "contextmenu" event (by a right click). Therefore, if you need programmatic access to items, you should register a "render" event listener and access those items within the scope of that listener.

oFieldContextMenu.subscribe("render", function () {

if (this.getItems() > 0) {

window.alert(this.getItem( 0));

}

});

On Oct 31, 2008, at 4:53 AM, meardon22 wrote:

Hello,

I have triedthis code. It's work, but I can't use the function getItem(), it's return undefined.