How to add context menu on svg element

I want to add some action on context menu. How to acheive that in aurelia?

Something like this i have…

 <g repeat.for="selectedRectangle of selectedRectangles" 
                transform="translate(${selectedRectangle.x0},${selectedRectangle.y0})"
               contextmenu="onRightClick(selectedRectangle)">

Any suggestions?

Thanks

2 Likes

I haven’t tried this, but you should be able to go:

contextmenu.delegate="onRightClick(selectedRectangle)"

The contextmenu event bubbles, so delegate or trigger can be used: Element: contextmenu event - Web APIs | MDN