After searching for hours, I cannot seem to figure out why a jQuery triggered click event is not passing the actual event to the click function. Here is an example: jsfiddle.
$(document).ready(function () {
$('tr').click(function (event) {
if (event.target.type !== 'checkbox') {
$(':checkbox', this).trigger("click");
}
});
$(':checkbox').click(function (event) {
console.log(event.shiftKey);
});
});
If I click the first checkbox, the console logs "false" as expected. Then, if I hold the shift key followed by checking the last checkbox, the console logs "true" as expected because as that box was clicked, shift was being held.
Now move over to the data and click on rows rather than checkboxes. Regardless of whether or not the shift key is being held as a row is clicked, the checkbox click event is fired, the box is checked/unchecked as appropriate, but event.shiftKey always returns false.
Why does triggering a click event from the row result in the originating event not being passed to the click handler?