sydcanem / bootstrap-contextmenu

Context menu plugin for Twitter's Bootstrap framework
http://sydcanem.com/bootstrap-contextmenu/
645 stars 193 forks source link

Getting at the DOM element that was right clicked? #58

Closed isbadawi closed 10 years ago

isbadawi commented 10 years ago

I have a sort of tree view -- it's a bunch of nested uls inside a div at the top-level. When I open the context menu on a tree item and select a menu item, onItem is invoked and the context argument is always set to the whole div, not the specific item (e.g. the li, or the span in the li's label) that was right-clicked.

My current workaround is to use $(document.elementFromPoint(e.clientX, e.clientY)) in the before handler, but this seems a bit hacky. Is there another way to get at the clicked element?

sydcanem commented 10 years ago

FYI, you can use scopes options for this. See https://github.com/sydcanem/bootstrap-contextmenu/issues/56.

isbadawi commented 10 years ago

Ah, great, thanks! I'd seen the scopes option mentioned in the README but hadn't really understood what it meant.