2014-03-03 50 views
0

我試着使用BootBox確認在ASP.NET MVC 5Bootbox確認不提交表單在ASP.NET MVC 5

我有這樣的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上的確定按鈕時,表單不會提交。我該如何解決這個問題?

回答

0

在該範圍內,$this按鈕,而不是表格。您無法提交按鈕。你可以這樣做:

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

'form'是否應該是我的表單的名字?我不知道如何找到表格名稱 – ASPCoder1450

+0

好吧,我已將我的表單命名爲'frm'並更改了代碼,但仍然無法在任何人的幫助下工作 – ASPCoder1450

+0

? – ASPCoder1450