I have looked for a while, but I can't find a solution for this. I want the following:
- Open an URL inside a Bootstrap modal. I have this working off course. So the content is loaded dynamically.
- When an user pushes a button inside this modal, I want the current modal to hide, and immediately after that, I want a new modal to open with the new URL (which the user clicked on). This content of the 2nd modal is also loaded dynamically.
- If the user then closes that 2nd modal, the first modal must come back again.
I have been staring at this for days, hope someone can help me.
Thanks in advance.
By using the following code you can hide first modal and immediately open second modal, by using same strategy you can hide second modal and show the first one.
if you use mdb use this code
It's not exactly the response but it's useful when you want to close the current modal and open a new modal.
In the html in the same button, you can ask to close the current modal with data-dismiss and open a new modal directly with data-target:
it is used to close the existing opened model. you can set it to the new model
None of the answers helped me since I wanted to achieve something which was exactly the same as mentioned in the question.
I have created a jQuery plugin for this purpose.
Working Fiddle for reference, JSFiddle: https://jsfiddle.net/gumdal/67hzgp5c/
You just have to invoke with my new API "
showStackedModal()
" instead of just "modal('show')
". The hide part can still be the same as before and the stacked approach of showing & hiding the modals are automatically taken care.