Ask questions and get good answers on mb.jQuery.components

I'm using e.target.id to get the control that was clicked on when the context menu was evoked but this value is blank when I call it from a submenu. This is of course because the submenu is called from the menu so the target is the upper level menu... any who. How can I pass that id to the submenu?

asked Jul 23 '10 at 17:47

Brian's gravatar image

Brian
132

edited Jul 24 '10 at 12:46

Matteo%20Bicocchi's gravatar image

Matteo Bicocchi ♦♦
1776129


there's a global variable $.mbMenu.lastContextMenuEl managed by the component that you can use as last menu called element. In your case the id would be: $.mbMenu.lastContextMenuEl.attr("id")

Bye, Matteo

answered Jul 24 '10 at 12:45

Matteo%20Bicocchi's gravatar image

Matteo Bicocchi ♦♦
1776129

This doesn't work.

(Jul 29 '10 at 14:25) Brian

$.mbMenu.lastContextMenuEl returns the UL that contains the LI that was clicked, not the LI that was lcicked.

(Jul 29 '10 at 14:52) Brian

I test the contextual menu applied to four LI elements adding a callback function onContextualMenu that returned the ID of the clicked element ($($.mbMenu.lastContextMenuEl).attr("id")) and the result was correct; it returns the exact ID of each clicked element... Don't know what's wrong on your code, sorry.

(Aug 01 '10 at 11:34) Matteo Bicocchi ♦♦

I have updated to the latest version of mbMenu and this still doesn't work. ($($.mbMenu.lastContextMenuEl).attr("id")) always returns the ID of the UL instead of the LI that was clicked. Do you have some test code that shows this working?

(Aug 04 '10 at 18:03) Brian

Finally figured it out, your response didn't make complete sense at first but now I got it. You're applying the cmVoice cMenu:'menu_name'} to each LI element instead of to the UL element. this solved the problem

(Aug 04 '10 at 18:14) Brian
Your answer
toggle preview

jQuery main site - Matteo Bicocchi