您好我正在尝试让确认对话框(引导框)工作。它显示确认对话框,但在按下确定按钮后不执行任何操作。
$(document).on("click", "#close", function (e) {
e.preventDefault();
var $this = $(this);
bootbox.confirm("Are you sure you want to close this Service Request? This operation cannot be reversed."
, function (result) {
if (result) {
$this.closest('form').submit();
} else {
console.log("user declined");
}
});
});
我相信这是错误的:
$this.closest('form').submit();
我的按钮是<td><a href="@Url.Action("CloseLog", "Log", new {id = item.LogID})"><span class="glyphicon glyphicon-trash" id="close"></span></a>
问题是如何让确定按钮工作?
编辑:我可以从按钮中的 onClick 调用此函数吗?如果有怎么办?
$(document).on("click", ".alert", function (e) {
var link = $(this).attr("href"); // "get" the intended link in a var
e.preventDefault();
bootbox.confirm("Are you sure?", function (result) {
if (result) {
document.location.href = link; // if result, "set" the document location
}
});
});