Skip to content
Advertisement

How to regenerate a modal with an active form?

I am running in to this issue that when I create a modal with an active form, and I close the modal without submitting the form, it doesn’t get reset when I try to recreate it.

Basically I want to load a different model by changing the parameters the button sends to the controller, while using the same action. However it looks like the action only executes the first time.

I use the following code for the button

JavaScript

Then in my controller I use the following

JavaScript

And at last my modal code that gets rendered.

JavaScript

So I want to be able to close the window, click a different button, and load a new model into the modal. All help is appreciated!

Advertisement

Answer

there is already a solution to this problem: reload-content-in-modal-twitter-bootstrap (your problem is more Bootstrap related)

In short, you will need to remove modal data on “hidden.bs.modal” event.

Bootstrap 3

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement