How to make icheck-material work with table rows?
carlo-fontanos opened this issue · 1 comments
carlo-fontanos commented
Hi,
I am trying to make a table row click to check the box. Bellow is what I have tried so far:
$('table').on('click', tr', function(e){
if(e.target.type !== 'checkbox'){
$(':checkbox', this).trigger('click');
}
});
Above works, but when I click the checkbox it triggers twice. Any idea how to fix this?
bantikyan commented
Hi @carlo-fontanos .
The problem you describe is not related with icheck-material, you will get same issue when dealing with regular checkboxes.
But maybe one solution will be if you change your code this way:
$('table').on('click', 'tr', function(e) {
if (e.target.parentElement.className.startsWith('icheck-material')) {
e.stopPropagation();
}
else {
$(':checkbox', this).trigger('click');
}
});