I want to detect if a user right-clicks a row in a table (datatables powered).
Now, the following code works fine if I use a non-ajax source:
oTable.$('tr').mousedown(function(e) {
if (e.which === 3) { //Right Mousebutton was clicked
window.sData = oTable.fnGetData( this );
jQuery(this).contextMenu({ x: e.pageX + 10, y: e.pageY + 10});
}
});
However, it doesn't work if I use an ajax source, so I looked around and tried:
jQuery('#myTable tbody').on( 'click', 'tr', function (e) {
alert("a click!");
if (e.which === 3) { //Right Mousebutton was clicked
alert("actually it was a right click!");
}
});
This code does detect regular clicks, but if fails to recognize a right click.
What am I doing wrong?