Reputation: 11
I'm using bootstrap and modals for partial views, I have a "loading" div to put in front of everything while getting the data. I can't put the loading div in front of the modal, already tried with z-index but still nothing.
This is my css:
.load {
position: absolute;
z-index: 500 !important;
height: 100%;
display: none;
border: 0;
padding: .5em 1em;
overflow: auto;
top: 0%;
left: 0%;
background: white;
width: 100%;
border: none;
opacity: 0.8;
}
.imagen_loading {
position: absolute;
z-index: 500 !important;
top: 35%;
left: 43%;
width: 300px;
height: 300px;
background: url('../../Content/img/gif/loader3.gif')
}
And this is my modal:
<div class="modal fade" id="modal_aprobar_transferencia" data-target="#modal_aprobar_transferencia">
<div class="modal-dialog">
<div class="modal-content" style="overflow:auto; width:90% !important; height:90% !important;">
<div class="modal-header orange">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title"><strong></strong>Transfers</h4>
</div>
<div class="modal-body">
@{
Html.RenderAction("lista_transferencias", "Almacen");
}
</div>
</div>
</div>
</div>
Edit:
<div class="container-fluid" style="padding-left:7em; padding-right:3em;">
<h3>Storehouse</h3>
<div class="row barra_menu" style=" ">
<div class="" style="float:left;">
<button type="button" class="btn btn-lg btn-info" href="#modal_formulario_altas" data-toggle="modal">
Receives
</button>
</div>
<div class="dropdown">
<button type="button" class="btn btn-lg btn-info dropdown-toggle" data-toggle="dropdown" style="float:left;">
Transfers <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a href="#modal_formulario_transferencias" data-toggle="modal">New transfer</a>
<a href="#modal_nuevos_sellos" data-toggle="modal">New seal package</a>
<a href="#modal_aprobar_transferencia" data-toggle="modal">See transfers</a>
<a href="#modal_recibir_transferencias" data-toggle="modal" class="btn_recibir_transferencia">Receive transfers</a>
</li>
</ul>
</div>
<div class="modal fade" id="modal_nuevos_sellos" data-target="#modal_nuevos_sellos">
<div class="modal-dialog" style="width:30% !important; height:15% !important;">
<div class="modal-content">
<div class="modal-header orange">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title"><strong></strong>Add seal package</h4>
</div>
<div class="modal-body">
<div class="form-group">
<div class="form-group col-3">
<label for="caja_inicio">First seal </label>
<input type="text" class="form-control numeric must " onkeydown="upperCaseF(this)" id="caja_inicio">
</div>
<div class="form-group col-3">
<label for="caja_final">Last seal</label>
<input type="text" class="form-control numeric must " onkeydown="upperCaseF(this)" id="caja_final">
</div>
<div class="form-group col-3">
<label for="caja_sucursal">Branch office </label>
<select type="text" class="form-control" id="caja_sucursal">
<option>Select</option>
<option value="1">Fortune</option>
<option value="2">Lucky one</option>
</select>
</div>
<div class="form-group col-3">
<br />
<button type="button" class="btn btn-primary mb-2" id="boton_guardar_sello" onclick="guardar_sellos_index(event);">Save</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="modal_aprobar_transferencia" data-target="#modal_aprobar_transferencia">
<div class="modal-dialog">
<div class="modal-content" style="overflow:auto; width:90% !important; height:90% !important;">
<div class="modal-header orange">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title"><strong></strong>Approval of transfers</h4>
</div>
<div class="modal-body">
@{
Html.RenderAction("lista_transferencias", "Almacen");
}
</div>
</div>
</div>
</div>
<!----LISTADO DE INVENTARIO----->
<div class="panel panel-default panel-primary">
<div class="panel-heading"><h4>Inventory</h4></div>
<div style="padding:1em; overflow:auto; ">
<table id="tabla_inventario" class="table table-striped ">
<thead>
<tr>
<th>@Html.DisplayNameFor(model => model.id_inventario)</th>
<th>@Html.DisplayNameFor(model => model.sucursal)</th>
<th>@Html.DisplayNameFor(model => model.po)</th>
<th>@Html.DisplayNameFor(model => model.mill_po)</th>
<th>@Html.DisplayNameFor(model => model.total)</th>
<th>@Html.DisplayNameFor(model => model.categoria_inventario)</th>
<th>@Html.DisplayNameFor(model => model.descripcion)</th>
<th>@Html.DisplayNameFor(model => model.estado)</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.id_inventario)</td>
<td>@Html.DisplayFor(modelItem => item.sucursal)</td>
<td>@Html.DisplayFor(modelItem => item.po)</td>
<td>@Html.DisplayFor(modelItem => item.mill_po)</td>
<td>@Html.DisplayFor(modelItem => item.total)</td>
<td>@Html.DisplayFor(modelItem => item.categoria_inventario)</td>
<td>@Html.DisplayFor(modelItem => item.descripcion)</td>
<td>@Html.DisplayFor(modelItem => item.estado)</td>
<td>
<button type="button" onclick="ver_item(@item.id_inventario)" class="btn btn-default glyphicon glyphicon-search " style="color:black; padding:0px 5px 0px 5px;"></button>
<a href="#" class="btn btn-default glyphicon glyphicon-edit btnEdit" data-value="@item.id_inventario" style="color:black; padding:0px 5px 0px 5px;" title="Editar Estilo"></a>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
<div id="loading" class="load">
<div id="spinner" class="imagen_loading" style=""></div>
</div>
My partial views are mostly the same, tables and edits.
I'd appreciate any help.
Upvotes: 1
Views: 9385
Reputation: 642
The trick in here is data-backdrop="false" style="background-color: rgba(0, 0, 0, 0.5);" by removing the default backdrop and create a dummy one by setting background color of the dialog itself with some alpha.
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="false" style="background-color: rgba(0, 0, 0, 0.5);">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">...</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
Notes: clicking on the background does not close the dialogue as is expected. Solution: So to achieve that you have to add some javascript code. Here is some example of how you can accomplish this.
$('.modal').click(function(event){
$(event.target).modal('hide');
});
HTML: place this within your body tag
<div id="LoaderWindow">
<div id="Loader"></div>
</div>
/* CSS for loading*/
.loader-window {
width: 100%;
height: 100%;
position: fixed;
z-index: 1051;
background: rgba(54, 70, 93, 0.95);
}
.loader {
position: absolute;
top:50%;
left:50%;
border: 8px solid #f3f3f3;
border-radius: 50%;
border-top: 8px solid #5BFEC8;
width: 60px;
height: 60px;
margin-top:-30px;
margin-left:-30px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
You have to use jquery to add class.
function loader(
operation
) {
if (operation == 'add') {
$('#LoaderWindow').addClass('loader-window');
$('#Loader').addClass('loader');
} else {
$('#LoaderWindow').removeClass('loader-window');
$('#Loader').removeClass('loader');
}
}
loader('add') would be used when you request data and after received a response use loader('remove');
Upvotes: 3
Reputation: 689
Try setting this styles to your loading div:
#loading {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 9999;
background: url(img/preloader.gif) center no-repeat #fff;
}
Be advised, the loading <div>
must be out of the modal <div>
.
HTML
<div id="loading"></div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"></div>
Upvotes: 0
Reputation: 168
When inspecting the modals within the Bootstrap (3 and 4) documentation, it looks like their default z-index is 1050. Did you try increasing the z-index of your loading div to something greater than 1050?
Upvotes: 1