I've made use of modal window for a wizard implementation which has around 4,5 steps. I need to destroy it completely after the last step(onFinish) and OnCancel step without having a page refresh. I can of course hide it, but hiding modal windows restores everything as such when i open up it again. Could anyone help me on this issue?
Thanks Any hints answers are helpful for me.
I had a same scenario where I would open a new modal on a button click. Once done, I want to completely remove it from my page... I use remove to delete the modal.. On button click I would check if modal exists , and if true I would destroy it and create a new modal ..
My approach would be to use the
clone()
method of jQuery. It creates a copy of your element, and that's what you want : a copy of your first unaltered modal, that you can replace at your wish : Demo (jsfiddle)The markup I used is the most basic, so you just need to bind on the right elements / events, and you should have your wizard reset.
Be careful to bind with delegated events, or rebind at each reset the inner elements of your modal so that each new modal behave the same way.
I have tried accepted answer but it isn't seems working on my end and I don't know how the accepted answer suppose to work.
This is working perfectly fine on my side. BS Version > 3
This is my solution:
this.$el.modal().off();
I have to destroy the modal right after it is closed through a button click, and so I came up with the following.
Note that this works with Bootstrap 3.
With ui-router this may be an option for you. It reloads the controller on close so reinitializes the modal contents before it fires next time.