In MVC, I built a table in a view, iterating over the “list” of the view model.
@foreach(var item in Model)
{
<tr id="row-@item.name">
<td>
@item.type
</td>
<td >
@Html.ActionLink((string)item.name, "Download", "FileUpload", new { rout = item.rout, fileName = item.name }, null)
</td>
<td>
@item.size
</td>
<td>
<a href="#" id="delete-file" del-url="@item.delete_url">Delete</a>
</td>
</tr>
}
when I load the page, I get a list of files with a delete link for each.
I implemented using jQuery the basic "delete row" method:
$('#delete-file').click(function() {
var delUrl = $(this).attr('del-url');
$.post(delUrl, null, removeRow(),'json')
});
function removeRow() {
$($('#delete-file').closest('tr')).fadeOut('slow');
}
When I click “delete” in one of the lines of the file, it works fine, but then if I click on the other (delete), nothing happens. The file is not deleted on the server, and the line is not deleted, as if it were completely ignored.
Tal l source
share