Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to tell what menu item was clicked in generic click function #29

Open
piller187 opened this issue Nov 2, 2016 · 1 comment
Open

Comments

@piller187
Copy link

I'm loading the menu dynamically in a plugin system. I define 1 function for the fun property of each menu item. There doesn't seem to be a way for me to tell when inside this function what menu item was clicked.

@leondanielking
Copy link

The tag itself (and the text) is available in the 2nd argument to your function or the event. From that you can extract the text and determine the menu item:

arguments[1].target
value: <li title="This is an example" class=iw-mSelected">Some Menu Item

or: event.target.innerText

If it's a submenu you can determine the parent item and figure out the context, should you have duplicate menu items.

Using JQuery: $(event.target).parent().parent()[0]
result: <li title="New..." class="iw-has-submenu iw-mTrigger iw-mSelected>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants