How do I get the id of type "invokedOn" by right click event using Bootstrap ContextMenu?
I am using Bootstrap 3.0 ContextMenu. here's a link http://jsfiddle.net/KyleMit/X9tgY/
I need to know how can I get the id or data-id of the clicked element. I am trying many tricks but I cannot get the id of the clicked element? For example, when I clicked on the line "Jacob", I got "Jacob" after clicking. I also need this <td data-id="user-3">
<a data-id="user-3">Jacob<a/>
<td/>
"Data-Id" string ?
I tried var $selectedFileId = $(this).closest('a').html();
oralert($(this).parent('a').html());
+3
source to share
2 answers
I am getting id by small additions in contextMenu handler, Changes
// click handler for context menu
function ContextMenuClickHandler() {
$(settings.menuSelector)
.off('click')
.on('click', function (e) {
$(this).hide();
var $invokedOn = $(this).data("invokedOn");
var $selectedMenu = $(e.target);
// My Changes
var $selectedFileId = $(this).data("invokedOn").find('.yourClass').attr('id');
settings.menuSelected.call($(this), $invokedOn, $selectedMenu, $selectedFileId);
});
}
0
source to share