jQuery-contextMenu icon indicating copy to clipboard operation
jQuery-contextMenu copied to clipboard

Context Menu Titles

Open Andrewhuk47 opened this issue 2 years ago • 1 comments

I have the contextmenu setup so that when I right click a table row I am able to retrieve the id of the item in the current row and perform actions based on the menu selection and the row ID.

Is it possible to update the menu title as setup in the docs below with data from the row that context menu was displayed on.

https://swisnl.github.io/jQuery-contextMenu/demo/menu-title.html

I can pull that data using this

var currentRow=$(this).closest("tr"); var usrname= 'User: ' + currentRow.find("td:eq(3)").text();

However I cannot seem to inject this into the menu title.

Can you help?

Andrewhuk47 avatar May 14 '23 19:05 Andrewhuk47

It should be pretty straight forward, if you follow the demo you mentioned here. Add a class like "data-title" to your contextMenu and add the .data-title css from the demo .

Now you can add a "show" event listener, in which you pull the data you need and add it as a data-attribute to the menu.

See this pen for a working example https://codepen.io/3m7ecc/pen/QWeRmjR

danielwillms avatar Nov 19 '24 10:11 danielwillms