I've got a table which has a checkbox in each row. I made an event handler for the click to move to another page, but I want to stop it from moving if I've clicked the checkbox. The following code is what I have:
Table layout
echo '<tr class="unread"><td><label class="fancy-checkbox"><input type="checkbox"><span> </span></label></td>';
echo '<td><span class="from">' . $message['message_from_first_name'] . '</span></td>';
echo '<td><span class="title">' . $message['subject'] . '</span> <span class="preview">- ' . strip_tags($message['message_preview']) . '</span></td>';
echo '<td><span class="timestamp">' . $message['datestamp'] . '</span></td>';
echo '<td style="display:none;">' . $message['message_id'] . '</td>';
echo'</tr>';
jQuery
<script>
$('table tr').click(function(event) {
if (event.target.type !== 'checkbox') {
var id = $("td:last-child", this).text();
$.redirect('?action=view-message', {message_id: id});
}
});
</script>
Aucun commentaire:
Enregistrer un commentaire