I've the following table with a link in the last cell. The table is populated with data via ajax, depending on the users input.
<table class="table-list">
<tbody>
<tr>
<td>...</td>
<td><a href="/link">Link</a></td>
</tr>
</tbody>
</table>
Because I like to have the whole row clickable, I use the following script to catch the onClick event. But the link is also in the table row and the onClick-Event gets fired infinity times until the script aborts with an "stackoverflow" error.
<script>
$(function() {
$('.table-list tr').live('click', function() {
$('a:last', this).click();
});
});
</script>
I tried to disable the event temporarily like below but it's not working.
<script>
$(function() {
$('.table-list tr').live('click', function() {
$(this).off('click');
$('a:last', this).click();
$(this).on('click');
});
});
</script>
I also tried some variations like addind and removing a class isClicked to the row etc. but nothing worked.
Any suggestions on this?