简体   繁体   English

Bootbox确认不提交ASP.NET MVC 5中的表单

[英]Bootbox Confirm Does Not Submit Form in ASP.NET MVC 5

Im trying to use BootBox Confirm in ASP.NET MVC 5. 我正在尝试在ASP.NET MVC 5中使用BootBox Confirm。

I have this JavaScript code: 我有以下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");
                    }
});

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

However, the form does not submit when I press the ok button on Bootbox. 但是,当我按Bootbox上的“确定”按钮时,表单没有提交。 How do I resolve this? 我该如何解决?

In that scope, $this is the button , not the form. 在此范围内, $thisbutton ,而不是表单。 You can't submit a button. 您无法提交按钮。 You could do: 您可以这样做:

$this.closest('form').submit();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM