[英]Two Bootstrap Modals freeze Page
I have the issue, that when I have declared two Bootstrap Modals at the end of my.cshtml-file, opening the first-declared Modal causes a freeze of the whole page.我有一个问题,当我在 my.cshtml 文件的末尾声明了两个 Bootstrap Modal 时,打开第一个声明的 Modal 会导致整个页面冻结。
If I change the order of the two modals, again the first-declared Modal causes the freeze.如果我改变两个模态的顺序,第一个声明的模态再次导致冻结。
Therefore I think it has to do something with the place of declaration.因此,我认为它必须与声明地点有关。
My general setup is like this (in this order):我的一般设置是这样的(按此顺序):
First Modal call:第一个模态调用:
@Ajax.ActionLink("Action1", "Action1_AL", "Controller",
new { id = x },
new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "Preview_first_modal", InsertionMode = InsertionMode.Replace, OnSuccess = "Open_first_modal()" },
new { @class = "btn btn-sm btn-default" })
Second Modal call:第二个模态调用:
@Ajax.ActionLink("Action2", "Action2_AL", "Controller",
new { id = y },
new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "Preview_second_modal", InsertionMode = InsertionMode.Replace, OnSuccess = "Open_second_modal()" },
new { @class = "btn btn-sm btn-default" })
First Modal setup:第一个模态设置:
<div class="modal fade" id="my_first_modal" role="dialog">
<div class="modal-dialog">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Title</h4>
</div>
<div class="modal-body align-self-center" id="Preview_first_modal">
@*PartialView*@
</div>
</div>
</div>
</div>
Second Modal setup:第二模态设置:
<div class="modal fade" id="my_second_modal" role="dialog">
<div class="modal-dialog">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Title</h4>
</div>
<div class="modal-body align-self-center" id="Preview_second_modal">
@*PartialView*@
</div>
</div>
</div>
</div>
Javascript: Javascript:
function Open_first_modal() {
$('#my_first_modal').modal('show');
}
function Open_second_modal() {
$('#my_second_modal').modal('show');
}
css-file: css 文件:
body {
}
th {
border: solid 1px #ddd !important;
}
td {
border: solid 1px #ddd !important;
}
table.dataTable.no-footer {
border-bottom: 1px solid #ddd;
}
.dataTables_wrapper .dataTables_filter input {
border: solid 1px #ddd;
}
thead > tr > th {
border-bottom-width: 2px !important;
}
body .modal-dialog {
max-width: 100%;
width: auto !important;
display: inline-block;
}
.modal {
z-index: -1;
display: flex !important;
justify-content: center;
align-items: center;
}
.modal-open .modal {
z-index: 1050;
}
In both modals I display a PartialView, which is loaded by the ActionLinks Action1_AL
and Action2_AL
.在这两种模式中,我都显示了一个由 ActionLinks
Action1_AL
和Action2_AL
加载的 PartialView。
In this setup clicking the button to call the first modal causes a freeze of the page.在此设置中,单击按钮调用第一个模式会导致页面冻结。
Do you know how I can handle this error?你知道我该如何处理这个错误吗? Thank you in advance!
先感谢您!
Edit: Added the.css-file编辑:添加了 .css 文件
I don't know what exactly went wrong, but replacing the modal properties css by我不知道到底出了什么问题,但是将模态属性 css 替换为
.modal {
text-align: center;
}
@media screen and (min-width: 768px) {
.modal:before {
display: inline-block;
vertical-align: middle;
content: " ";
height: 100%;
}
}
.modal-dialog {
display: inline-block;
text-align: left;
max-width: 100%;
width: auto !important;
vertical-align: middle;
}
solved the problem.解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.