Dynamically loaded Bootstrap Modal does not scroll on iOS 9
Created by: jkrehm
Using Bootstrap 3, when I load content into a modal on the show
event, scrolling on iOS 9 devices does not work. It works correctly on every other device that I've tried, including iOS 8. I think the DOM doesn't update the
handleUpdate
function doesn't fix the issue, either.
I've created a minimal example on Codepen at http://codepen.io/jkrehm/full/LpRzJV/ (code available here).
The most relevant code is this:
// Show loader & then get content when modal is shown
$modal.on('show.bs.modal', function(e) {
$(this).find('.modal-body')
.html('loading...')
.load('https://baconipsum.com/api/?type=meat-and-filler¶s=10', function() {
// Use Bootstrap's built-in function to fix scrolling (to no avail)
$modal.modal('handleUpdate');
});
});
If I change the code so the content is loaded before the modal is shown, things work fine, but there's no loading indicator for the user (just a pause of indeterminate length after they click the button and before the modal appears).
What can we do to convince iOS 9 to recalculate the .modal-body
's scroll height? I've tried a number of things, and the only "work around" that works reliably is to hide .modal-body
and show it again.
I've also created a StackOverflow question in case someone else runs into the issue and figures out a fix.