I have the following HTML table is rendered to my browser.I am creating this table from my ASP.NET codebehind file.
<table Class="tblTradeInCart">
<tr class="tblCartHeader">
<td>Item</td>
<td>Model</td>
<td> Price</td>
<td>Delete</td>
</tr>
<tr id="tr_15_1">
<td><img src="dia/images/LGVX9700.jpg" width="50" height="50" /></td>
<td>LG VX9700</td>
<td>$ 122</td>
<td><a href='#' onclick="deleteItem(15,1,'tr_15_1')"><img src='..\Lib\images\NCcross.gif' style='border:0px'></a></td>
</tr>
<tr id="tr_11_8">
<td><img src="dia/images/NOK5610.jpg" width="50" height="50" /></td>
<td>NOKIA 5610</td>
<td>$ 122</td>
<td><a href='#' onclick="deleteItem(11,8,'tr_11_8')"><img src='..\Lib\images\NCcross.gif' style='border:0px'></a></td>
</tr>
<tr id="tr_14_9">
<td><img src="dia/images/NOKN95.jpg" width="50" height="50" /></td>
<td>NOKIA N95</td>
<td>$ 91.5</td>
<td><a href='#' onclick="deleteItem(14,9,'tr_14_9')"><img src='..\Lib\images\NCcross.gif' style='border:0px'></a></td>
</tr>
</table>
and In my javascript i have the delete function as follows
function deleteItem(modelId,itemindexId, rowId)
{
$.get("RemoveFromCart.aspx",{ model:modelId,cartItem:itemindexId,mode:"removefromcart",rand:Math.random() } ,function(data)
{
//document.getElementById(rowId).style.display = "none";
var row=$("#"+rowId);
row.fadeOut(1000);
});
}
But when i call the deleteItem function, I am not getting the fading Effect.Its simply hiding the row like the display="none".
Can any one guide me how to fix this ?
There is a problem in jQuery when hiding trs
. This is the current workaround until they do something similar in the core, if they decide to.
row.find("td").fadeOut(1000, function(){ $(this).parent().remove();});
This basically hides the tds
in the row, instead of the actual row. Then it removes the row from the DOM. It works in all browsers I believe. You could target IE specifically though if needed.