Answer the question
In order to leave comments, you need to log in
Bootstrap 3, how to fix parent page when modal window is tricky called?
When a modal window is opened, a class is added to the body .modal-open { overflow: hidden; }
and the site page is fixed.
In my case, the second modal window is called directly from the open modal window (the first one is closed at the same time so that they do not overlap each other).
So, with such a call to the second window, modal-open for some reason is not added to the body and, accordingly, the parent page scrolls.
Nothing terrible, but annoying.
How to fix this moment?
I'm trying to force it like this:
$('#Modal2').on('show.bs.modal', function (e) {
$('body').addClass('modal-open');
})
$('#Modal2').on('show.bs.modal', function (e) {
$('body').css('overflow','hidden');
})
$('#Modal2').on('show.bs.modal', function (e) {
$('body').css('overflow','hidden');
});
$('#Modal2').on('hidden.bs.modal', function (e) {
$('body').css('overflow','auto');
})
Answer the question
In order to leave comments, you need to log in
hang a handler on all id, you only have a second window like. it is also recommended to clear the cache
$('#Modal2, #Modal1').on('show.bs.modal', function (e) {
$('body').css('overflow','hidden');
});
$('#Modal2, #Modal1').on('hidden.bs.modal', function (e) {
$('body').css('overflow','auto');
$(this).removeData('bs.modal');
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question