How can I retreive the ids of contexts menu just like in https://github.com/mar10/jquery-ui-contextmenu/blob/master/README.md, but with additionally provided IDs
<div id="container">
<div id="menu1" class="hasmenu">AAA</div>
<div id="menu2" class="hasmenu">AAA</div>
</div>
in the select method?
$("#container").contextmenu({
delegate: ".hasmenu",
menu: [
{title: "Copy", cmd: "copy", uiIcon: "ui-icon-copy"}
],
select: function(event, ui) {
alert("select " + ui.target.id); // ui.target.id fails!!!
}
});
ui.targetis a jQuery element, not a plain javascriptHTMLElement. You can get at that with the[0]suffix ($(ui.target)[0].id) or, more readably, just use the jQuery attribute accessor function:Here's a link to a fiddle example and a stack snippet below