jakiestfu / Context.js

Contextual Menus with Twitters Bootstrap.css
http://lab.jakiestfu.com/contextjs/
248 stars 62 forks source link

Selecting element to which context menu is attached #24

Closed michaelbilow closed 1 year ago

michaelbilow commented 9 years ago

Hi!

First off, this tool's really great, thanks a lot for releasing it. I've attached the context menu to a class of elements in my code, and I want to access the element from which the context menu was raised. Is there a clean way to do it? I'm looking for something like the following:

context.attach(".my-class", [
{text: 'Act on right-clicked element', action: function(e){
            e.preventDefault();
                        // Is there a way to get a selector for the clicked item?
            }}]
AchoArnold commented 9 years ago

@chuyelchulo Presently, there is no way to do that. There is an issue for this.

Checkout this pull request which addresses this problem.

michaelbilow commented 9 years ago

Thanks @najela, that's really useful. I think I should be able to patch it myself based on that pull request.