A
A
Artyom2016-04-14 16:33:12
JavaScript
Artyom, 2016-04-14 16:33:12

How to reset modal window?

Feedback form in a modal window .
After the submit, it turns into this:
4a3c1038d3d041d389a8ea7d34ca5f2e.png
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

3 answer(s)
A
Alex, 2016-04-14
@SlampD

{
        $(".result").addClass( "hidden" );
        $("#myModalLabel").html('Сообщение отправлено!');
        $("#cButton").removeClass( "hidden" );
        $(".modal-header").addClass("text-center");
        $('#name').val('');
        $('#email').val('');
    $('#message').val('');
        $('#phone').val('');
    }

On pressing the button, all these values ​​\u200b\u200bshould be returned to their original position
$(".result").removeClass( "hidden" ); .....

N
Niomin, 2016-04-14
@Niomin

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.

M
Mikhail, 2016-04-14
Chirskiy @chirskiy_mixail

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 question

Ask a Question

731 491 924 answers to any question