So, I'm using this code to open another modal window in a current opened modal window:
<a onclick=\"$('#login').modal('hide');$('#lost').modal('show');\" href='#'>Click</a>
What happens is, that for like 500ms the scrollbar will duplicate. I guess because the current modal is still fading out. However it looks very un-smooth and stuttering.
I would appreciate any suggestions to solve this issue.
Also, is the way building this in an onclick-event unprofessional?
I'm working with the bootstrap version 3.0.
Edit: I guess it's neccesary to reduce the time of fading out a modal. How is this possible?
Twitter docs says custom code is required...
This works with no extra JavaScript, though, custom CSS would be highly recommended...
The answer given by H Dog is great, but this approach was actually giving me some modal flicker in Internet Explorer 11. Bootstrap will first hide the modal removing the 'modal-open' class, and then (using H Dogs solution) we add the 'modal-open' class again. I suspect this is somehow causing the flicker i was seeing, maybe due to some slow html/css rendering.
Another solution is to prevent bootstrap in removing the 'modal-open' class from the body element in the first place. Using bootstrap 3.3.7, this override of the internal hideModal function works perfect for me.
In this override, the 'modal-open' class is only removed when there are no visible modals on the screen. And you prevent one frame of removing and adding a class to the body element.
Just include the override after bootstrap have been loaded.
To open another modal window in a current opened modal window,
you can use bootstrap-modal
bootstrap-modal DEMO
For bootstrap 4, to expand on @helloroy's answer I used the following;-
The advantage of the above is that it won't have any effect when there is only one modal, it only kicks in for multiples. Secondly, it delegates the handling to the body to ensure future modals which are not currently generated are still catered for.
Update
Moving to a js/css combined solution improves the look - the fade animation continues to work on the backdrop;-
combined with the following css;-
This will handle modals nested up to 4 deep which is more than I need.
Try this:
This simple hack works for me.