Context.js icon indicating copy to clipboard operation
Context.js copied to clipboard

Selecting element to which context menu is attached

Open michaelbilow opened this issue 9 years ago • 2 comments

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?
            }}]

michaelbilow avatar May 05 '15 21:05 michaelbilow

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

Checkout this pull request which addresses this problem.

AchoArnold avatar May 05 '15 22:05 AchoArnold

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

michaelbilow avatar May 05 '15 22:05 michaelbilow