Bootbox Conform未显示单击链接按钮 . 尝试了很多东西,最近安装了BootBox,Bootstrap和Jquery . 似乎点击按钮后,对话框被创建在右上方的下方导航栏,因为鼠标图标在2点处变化,但是符合模型或对话框不显示或出现 . 这是我的Html代码:
<table id="customers" class="table table-bordered table-hover">
<thead>
<tr>
<th scope="col">Customers</th>
<th scope="col">Membership Type</th>
<th scope="col">Delete</th>
</tr>
</thead>
<tbody>
@foreach (var customer in Model)
{
<tr>
<td scope="row">@Html.ActionLink(customer.Name,"Edit","Customers",new { customer.Id },null)</td>
<td scope="row">@customer.MembershipType.Name</td>
<td scope="row"><button data-customer-id="@customer.Id" class="btn btn-link js-delete">Delete</button>
</tr>
}
</tbody>
</table>
这是我的Java脚本代码:
@section scripts
{
<script>
$(document).ready(function () {
$("#customers .js-delete").on("click", function () {
//e.preventDefault();
var butten = $(this);
bootbox.alert("Are You sure You want to Delete this Customer?")
bootbox.confirm("Are You sure You want to Delete this Customer?", function (result) {
if (result) {
$.ajax({
url: "/api/customers/" + butten.attr("data-customer-id"),
method: "DELETE",
success: function () {
butten.parent("tr").remove();
}
});
}
});
//if (confirm("Are You sure You want to Delete this Csustomer?")) {
//}
});
});
</script>
}
此外,如果我使用默认确认而不是bootbox确认,一切正常,但点击删除按钮记录被删除但页面不刷新 .
2 回答
我找到了解决方案 . 看起来Bootbox与Bootstrap 4.0及更高版本有问题 . 我安装了bootstrap 3.3.7 . 现在Bootbox工作正常 . 有任何建议如何使它与bootstrap 4.0和更新?
我设置了一个片段,用于BS4和jquery 3.3.1与Bootbox 4.4.0
为简单起见,我删除了你的ajax调用,否则我没有看到问题 .