Reset Bootstrap Modal if not all form steps are co

2019-07-19 04:25发布

问题:

I am having a little issue with a Twitter Bootstrap modal. It is customized pretty far.

What we have done is open a modal when the user click complete objective, then press submit button, post() to controller, then load() the next screen inside the modal body. This is a survey that is optional. The user can then fill it out and receive a thank you message which disappears after 3 secs.

Here is the issue: 1. If modal window is closed on survey and another objective is clicked to complete, the survey still shows up in the modal. 2. Same thing happens once user completes survey, try to complete another and the thank you modal pops up.

Question How can I use jQuery to create some sort of function that will reset the modal on close... or how to reset it once the success message is reached.

I guess just know how to create a function that will reset it, then i can call that whenever needed.

Got any ideas?

回答1:

Found the solution!

using the function built in

 $("#myModal").on("hidden", function() { 
 //do something
 });

I was able to reset the html in my modal-body and the buttons as well using simple css class changes.