アイテムを削除するためにサーバーにajaxリクエストを行っていますが、ブートボックス経由でフロントエンドで削除する必要がありますが、私の応答はOKですが、フロントエンドでは削除されません。アイテムを削除する<tr> bootbox
function Delete(data) {
bootbox.confirm({
message: "Deseja Excluir o item?",
buttons: {
confirm: {
label: 'Yes',
className: 'btn-danger'
},
cancel: {
label: 'No',
className: 'btn-success'
}
},
callback: function (result) {
if (result) {
$.ajax({
url: "/Ponto/DeleteAjuste/" + data,
type: "POST",
contentType: "application/json;charset=UTF-8",
dataType: "json",
success: function (result) {
$(this).closest("tr").remove();
},
error: function (errormessage) {
alert(errormessage.responseText);
}
});
}
console.log('This was logged in the callback: ' + result);
}
});
@foreach (var item in ViewBag.Ajuste)
{
<tr>
<td>@item.Data</td>
<td>@item.Descricao</td>
<td>@item.Horas</td>
<td >
<a class="btn btn-danger btn-excluir" role="button" onclick="Delete(@item.Data)" ><i class="glyphicon glyphicon-trash"></i> Excluir</a>
</td>
</tr>
}
私はこの問題はここにあると思う: $(この).closest( "TR")を削除();。ループしながら、コントローラおよびあなたからあなたの
<a class="btn btn-danger btn-excluir" id="item_{@item.id}" role="button" onclick="Delete(@item.Data)" ><i class="glyphicon glyphicon-trash"></i> Excluir</a>
戻りIDに識別子(IDまたはクラス)を追加