[ 2 posts ]

Aditya Gaur

  • Username: agaur
  • Joined: Sun Mar 06, 2011 10:29 pm
  • Posts: 15
  • Offline
  • Profile

YUI 2 context menu.

Post Posted: Wed Jul 06, 2011 4:36 am
+0-
Is there a way to get the name of the context menu item clicked. For example in the following code:
Code:
 function showContextMenu(eventType, args) {
        var menuItem = args[1]; // The MenuItem that was clicked
        switch (menuItem.index) {
        case 0:
            // do some thing
            break;
        case 1:
            // do some other thing
            break;
        case 2:
            // do something else
            break;
        }
    }

I use the index of the menu item to call functions. I want to call functions based on the name of the menu item clicked to increase readability. I am unable to get the name using the "value" field in menu item. Is there a way to do this.

Matt Parker

YUI Contributor

  • Username: mattatlamplight
  • Joined: Mon Apr 20, 2009 12:03 pm
  • Posts: 466
  • Location: London UK
  • GitHub: mattparker
  • Gists: mattparker
  • Offline
  • Profile

Re: YUI 2 context menu.

Post Posted: Wed Jul 06, 2011 6:19 am
+0-
Hi,

Assuming this function is your onclick handler for the menu items, there's a third argument that has the menu item value:

Code:
function showContextMenu(eType, aArgs, oItem) {
   var value = oItem.value;
   // ... etc
}


Matt
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
cron