0

我试图在 ASP.NET MVC 5 中使用 BootBox Confirm。

我有这个 JavaScript 代码:

$(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.submit();
                    } else {
                        console.log("user declined");
                    }
});

使用此按钮:<td><a href="@Url.Action("CloseLog", "Log", new {id = item.LogID})"><span class="glyphicon glyphicon-trash" id="close"></span></a>

但是,当我按下 Bootbox 上的确定按钮时,表单没有提交。我该如何解决这个问题?

4

1 回答 1

0

在该范围内,$this按钮,而不是表单。您不能提交按钮。你可以这样做:

$this.closest('form').submit();
于 2014-03-03T22:36:27.747 回答