https://jsfiddle.net/e6x4hq9h/
When opening the first modal, it works correctly and removes the background scrollbar.
However, when trying to open a modal from within that modal, it causes the scroll to jump to the background.
I have researched various solutions but none of them seem to solve this issue. I have tried everything mentioned on this page: Bootstrap modal: close current, open new as well as others.
Here is the Javascript code I have been using:
// Only one modal should be visible at a time
$('#myModal2').on('show.bs.modal', function (e) {
$('#myModal').modal('hide');
})
.on('hide.bs.modal', function (e) {
$('#myModal').modal('show');
});
Update: It is important for both the first and second modals to allow scrolling, which can be observed in this updated fiddle: https://jsfiddle.net/e6x4hq9h/21/