簡體   English   中英

如何防止 Bootstrap Modal 自動關閉?

[英]How to prevent the Bootstrap Modal from auto closing?

我在 ASP.NET MVC web 應用程序的“索引”視圖中有引導模式(通過按鈕打開)。 在這個模式中,我調用填充三個 texbox 的存儲過程(帶有輸入參數)。 之后我的模式自動關閉。 當我再次打開它時,texboxes 被填滿了。 如何防止這種自動關閉?

帶有存儲過程的“索引”視圖的一部分:

<!-- Input parameter to execute stored procedure "GetMesData" -->
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
@Html.TextBox("send")
<input type="submit" value="Send" />
}

<!-- Textboxes which are fill thanks to stored procedure "GetMesData" -->
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
<br>@Html.TextBoxFor(x => x.UserResponse.MatNumber, Model.UserResponse.MatNumber.ToString())<br />
<br>@Html.TextBoxFor(x => x.UserResponse.SlurryNumber, Model.UserResponse.SlurryNumber.ToString())<br />
<br>@Html.TextBoxFor(x => x.UserResponse.BatchNumber, Model.UserResponse.BatchNumber.ToString())<br />
}

JavaScript - 可能我應該在這里添加一些東西來防止這種自動關閉

<script>
$(document).ready(function(){
  $("#myBtn").click(function(){
      $("#myModal").modal('show');
  });
});
</script>

我的“家”controller 方法帖子:

//Execute stored procedure "GetMesData" with input parameter
[HttpPost]
public ActionResult Index(OrderListOfClass ttt, string send)
{

//calling stored procedure

return View()
}

為了防止使用 jQuery 在外部單擊時關閉引導模式。 您必須將選項背景用於 static 選項,將鍵盤用於 false 選項。 這在您單擊按鈕並打開模式后有效。

$('#MymodalPreventScript').modal({ 背景:'靜態',鍵盤:假 });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM