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.
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:
function Open_first_modal() {
$('#my_first_modal').modal('show');
}
function Open_second_modal() {
$('#my_second_modal').modal('show');
}
css-file:
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
.
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
I don't know what exactly went wrong, but replacing the modal properties css by
.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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.