3

I am using Bootstrap 3.0 ContextMenu. here is a link http://jsfiddle.net/KyleMit/X9tgY/

I need to know how i can get the id or data-Id of the clicked element. i try many of the tricks but i cant get the clicked element id? Like when i clicked on "Jacob" row i get the "Jacob" after clicked. I also need from this line
<td data-id="user-3"> <a data-id="user-3">Jacob<a/> <td/> "data-Id"?

i tried var $selectedFileId = $(this).closest('a').html(); or alert($(this).parent('a').html());

Qasi
  • 31
  • 4

2 Answers2

0

Use this code for get clicked element id

jQuery(document).on('click', function(e){
console.log(e.target.id);
})
Harutyun Abgaryan
  • 2,013
  • 1
  • 12
  • 15
  • you right harutyun but dude from this i can get the id of Menu item not from the data. i need the id of the row where i click on my page item? – Qasi Sep 29 '14 at 23:35
0

I get the id by little additions in the 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);
    });
}  
Qasi
  • 31
  • 4