[jQuery] Delete a table row with JQuery
Hi
I have a table where I browse the records of the database. I
implemented a delete button in each row. When I press this button, I
send an ajax request to the server. If the response is ok, I need to
delete the row of the table that have the data I was deleted.
By example:
HTML Code:
=========
<table id="explorer">
<tr id="row-1">
<td>News title</td>
<td><a href="javascript:deleteRow(1, "row-1">Delete</a></td>
</tr>
[...]
<tr id="row-10">
<td>News title</td>
<td><a href="javascript:deleteRow(10, "row-10">Delete</a></td>
</tr>
</table>
Javascript Code:
===========
function deleteRow(iId, sRowId)
{
jqRow = $("#" + sRowId);
/* Change de color of row */
jqRow.addClass("todelete");
if (window.confirm("¿Desea borrar esta noticia?"))
{
/* Change de color again */
jqRow.removeClass("todelete");
jqRow.addClass("deleting");
if (AJAX_RESPONSE_OK)
{
jqRow.fadeOut("slow", function()
{
jqRow.remove();
window.alert("Record delete");
});
}
}
}
When the code is executed, in the table appears an empty space instead
of the row. If I not use the fadeOut effect, the row disappears
correctly.
Could you Help me?
Thanks in advance
Pablo