我使用了甜蜜的警報對話框來確認洗掉。當我在表單中輸入模型的id值時,正確的值沒有被發送,而少發送了一個數字。
不使用表單也能發送正確的id值。
請告訴我哪里有問題。
請告訴我問題出在哪里,以及我如何才能解決它。
。$(".ajax_delete1")。 on("click", function validateForm(event) {
event.preventDefault(); //防止表單提交。
var form = $('#ppp'); //儲存表單。
swal({
title: "??? ?? ??? ???? ??? ???? ????? ?????"/span>,
text: "??? ???? ??? ??? ??? ???? ???? ????????? ????!",
icon: "警告"。
showCancelButton: true,
dangerMode: true,
confirmButtonColor: '#DD6B55'。
confirmButtonText: "???",
cancelButtonText: "??????",
})
.then((willDelete) =>/span> {
if (willDelete) {
form.submit()。
} else {
swal("???? ??? ??? ???!") 。
}
});
});
@foreach (var item in Model) {
<tr>
<td>@item.projectName</td>
<td>/span>@item.projectMagName</td>/span>
<td style="width:250px">
<div class="text-center row d-flex justify-content-between"/span>>
<div class="mt-1">
<a class="fa-edit" style="font-size:28px; color: darkblue" asp-controller="Home"/span> asp- action="EditProject" asp-route-id="@item。 projectID"></a>。
</div>/span>
<div style="margin-top:3px">
< form asp-controller="Home" asp-action="RemoveProject" asp-route-id="@item。 projectID" method="post" id="pop">
< a class="fa-trash-o ajax_delete1" style="font-size。28px; color: red; cursor: pointer;"></a>
</form>
</div>/span>
<div style="margin-top:1px">
< a class="btn btn-sm btn-outline-primary" asp-controller="Home" asp-action="ProjectDetails" asp-route-id="@item。 projectID">????</a>
< a class="btn btn-sm btn-outline-secondary" asp-controller="Home" asp-action="PayShow" asp-route-id="@item。 projectID">??????</a>/span>。
</div>/span>
</div>/span>
</td>/span>
</tr>
}
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
uj5u.com熱心網友回復:
根據你的描述,我發現你使用了$('#pop');,如果你使用查詢代碼,它將永遠使用第一個表單。
我建議你可以嘗試使用var form = event.target.closest("form");,這將會找到A標簽的封閉表單元素。
更多的細節,你可以參考下面的代碼:
$(".ajax_delete1") 。 on("click", function validateForm(event) {
event.preventDefault(); //防止表單提交。
var form = event.target.closest("form"); //儲存表格
swal({
title: "??? ?? ??? ???? ??? ???? ????? ?????"/span>,
text: "??? ???? ??? ??? ??? ???? ???? ????????? ????!",
icon: "警告"。
showCancelButton: true,
dangerMode: true,
confirmButtonColor: '#DD6B55'。
confirmButtonText: "???",
cancelButtonText: "??????",
})
.then((willDelete) =>/span> {
if (willDelete) {
form.submit()。
} else {
swal("???? ??? ??? ???!") 。
}
});
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/328653.html
標籤:
