I have page where it displays a list of orders. I'm trying deleting row of the table when a user clicks on a button, but its just removing the first row and when i try to delete the second or third row it cannot be delete it. Can anyone please help me or point me in to the right direction? Thanks in advance.
View:
<table id="Tableitem" class="table">
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
<div class="product-title">
<a href="/Main/Produktdetaljer/@item.ProductId?proid=@item.ProductId">
@Html.DisplayFor(modelItem => item.ProductName)
</a>
</div>
</td>
<td>
<ul>
<li>
<div class="base-price price-box">
<span class="price">
@Html.DisplayFor(modelItem => item.Price)
</span>
</div>
</li>
</ul>
</td>
<td class="QuantityOfProduct@(item.ProductId)">
@Html.DisplayFor(modelItem => item.Quantity)
</td>
<td>
<i data-id="@item.ProductId" class="fa fa-trash cart-remove-item removeproduct"></i>
</td>
</tr>
}
</tbody>
</table>
Javascipt:
$("i.removeproduct").click(function (e) {
e.preventDefault();
var $this = $(this);
var productId = $(this).data("id");
var url = "/cart/RemoveProduct";
$.get(url, { productId: productId }, function (data) {
// i used .load for not refreshing page
$('#Tableitem').load(document.URL + ' #Tableitem');
});
});