Answer the question
In order to leave comments, you need to log in
How to reset modal window?
Feedback form in a modal window .
After the submit, it turns into this:
Closes, everything is OK. But if you click on the contact form again, without refreshing the page, it will open in the same form. How to realize this moment? So that after closing the modal, it opens in its original form? There is an option to reload the page after closing, but it seems to me that this is not very beautiful.
UPD.
Indeed, there was another problem. In addition to the "close" button itself and the cross, it is also closed by "Esc" and a click outside the modal. How to track these clicks?
Answer the question
In order to leave comments, you need to log in
{
$(".result").addClass( "hidden" );
$("#myModalLabel").html('Сообщение отправлено!');
$("#cButton").removeClass( "hidden" );
$(".modal-header").addClass("text-center");
$('#name').val('');
$('#email').val('');
$('#message').val('');
$('#phone').val('');
}
$(".result").removeClass( "hidden" ); .....
For example, you can use two modal windows: hide the first, show the second.
Or redraw the first one at the opening stage. Or closing the second.
What kind of perverted ideas do you have, gentlemen, you can take a template engine, for example, this handlebarsjs.com , keep the modal window 1, call it on click, delete it completely on closing, and when you are next. once you call it, it will be with empty values and you don’t need to fence and clean up a bunch of classes.
The same thing is possible without a templating engine, it just simplifies the task and you don’t have to cheat in the markup in JS
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question