I have a table, each row assigned a unique ID so I can click on the row, grab it with jquery and edit the data for that row. I like clicking on the entire row for convenience and it makes it easier for the user..
In the last column, I have an X which I want to be able to click on to delete that row. Again, it has a unique ID so I can identify each row. My jquery looks something like this..
$('.delrow').click(function(e) {
e.preventDefault();
var id = $(this).attr('id');
id = id.substr(3);
if (confirm('Are you sure you want to delete this row?')) {
$.ajax({
url: "/rowdelete/?delid="+id,
success: function(data)
{
location.href="/";
}
});
} else {
return false;
}
});
This should delete the row then return to the homepage. What it does is delete the row then continue on into my edit module with a row id of null since the default action for the row click was to do exactly that. I presume at this point that preventDefault only applies to form actions and thus, won't work in this instance. How can I override the default row click action?
Thanks!