I use BlockUI
plugin in my app to block user screen when some action are executed. Some times when blockUI is in use bootstrap modal opens with it's modal-backdrop which made background much darker.
$.fn.myBlockUI = function () {
var loader = $('#img-loader');
.blockUI({
message: loader,
css: {
border: 'none',
padding: '5px',
'background-color': 'transparent',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .6,
color: '#fff',
cursor: 'wait'
}
});
}
This is my function which i add to ajax call on beforeSend
.
$.fn.myBlockUI = function () {
var loader = $('#img-loader');
$('.modal').on('shown.bs.modal', function(e) {
$(".modal-backdrop").addClass('modal-backdrop-no-background');
});
$('.modal').on('hidden.bs.modal', function(e) {
$(".modal-backdrop").removeClass('modal-backdrop-no-background');
});
$.blockUI({
message: loader,
css: {
border: 'none',
padding: '5px',
'background-color': 'transparent',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .6,
color: '#fff',
cursor: 'wait'
}
});
}
this is my "solution" which doesn't work now. I thought when i call this function add class with opacity : 0
to remove one background, but this doesn't work.
General Sibling Selector selects all elements that are siblings of a specified element.
element ~ element {...}
Example:
.modal-backdrop {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1040;
background-color: #000;
opacity: 0.5;
}
.modal-backdrop ~ .modal-backdrop {
display: none;
}
<div class="modal-backdrop"></div>
<div class="modal-backdrop"></div>
<div class="modal-backdrop"></div>