Close the form after submitting?

Good time of day. Prompt such thing: There is a form that is processed by the Remodal plugin, works fine and the message sends, but how to do that after sending a message it was closed, not hanging open? In the plugin js code is minimized and very difficult to understand what and where. You can throw the plugin what it is. Someone tell me how? Can a php file have something to add?
I tried to add the variable to work with form as object and close it via the object.close(); but not strong in js and that didn't work...
June 10th 19 at 14:40
2 answers
June 10th 19 at 14:42
Solution
Honestly never used this modal window. But according to the documentation it is necessary to do the following

var inst = $('[data-remodal-id=modal]').remodal(); // initialize the window

//perform ajax request
//if jquery do, as follows
$.post(ajax_url, data, function(result){

 //perform actions after a successful send
inst.close();

}, "json")
I'm about the same I suppose that would have to do, only see, here's the code to send via Ajax.. and where to insert Klose?
$(document).ready(function(){$("form").submit(function(){var formID=$(this).attr('id');var formNm=$('#'+formID);var message=$(formNm).find(".msgs");var formTitle=$(formNm).find(".formTitle");$.ajax({type:"POST",url:'https://site.ru/mail.php',data:formNm.serialize(),success:function(data){message.html(data);formTitle.css("display","none");setTimeout(function(){$('.formTitle').css("display","block");$('.msgs').html(");$('input').not(':input[type=submit], :input[type=hidden]').val(");},3000);},error:function(jqXHR,text,error){message.html(error);formTitle.css("display","none");setTimeout(function(){$('.formTitle').css("display","block");$('.msgs').html(");$('input').not(':input[type=submit], :input[type=hidden]').val(");},3000);}});return false;});var $input=$('.form fieldset > input');$input.blur(function(e){$(this).toggleClass('filled',!!$(this).val());});}); - Eloy commented on June 10th 19 at 14:45
From next time send it from a normal code and not a minified

$(document).ready(function() {
 $("form").submit(function() {
 var formID = $(this).attr('id');
 var formNm = $('#' + formID);
 var message = $(formNm).find(".msgs");
 var formTitle = $(formNm).find(".formTitle");
$.ajax({
 type: "POST",
 url: 'https://site.ru/mail.php',
 data: formNm.serialize(),
 success: function(data) {
message.html(data);
 formTitle.css("display", "none");
 setTimeout(function() {
 $('.formTitle').css("display", "block");
$('.msgs').html(");
 $('input').not(':input[type=submit], :input[type=hidden]').val(");

 //your code

 }, 3000);
},
 error: function(jqXHR, text, error) {
message.html(error);
 formTitle.css("display", "none");
 setTimeout(function() {
 $('.formTitle').css("display", "block");
$('.msgs').html(");
 $('input').not(':input[type=submit], :input[type=hidden]').val(");
 }, 3000);
}
});
 return false;
});
 var $input = $('.form fieldset > input');
 $input.blur(function(e) {
 $(this).toggleClass('filled', !!$(this).val());
});
});
- jaeden33 commented on June 10th 19 at 14:48
Understood, I will consider. And here you already fixed something?Look and do not see changes.. - Eloy commented on June 10th 19 at 14:51
inst.close(); you need to embed an ajax request? in about
$("form").submit(function() {
 var formID = $(this).attr('id');
 var formNm = $('#' + formID);
 var message = $(formNm).find(".msgs");
 var formTitle = $(formNm).find(".formTitle");
$.ajax({
 type: "POST",
 url: 'https://site.ru/mail.php',
 data: formNm.serialize(),
 success: function(data) {
message.html(data);
 formTitle.css("display", "none");
 setTimeout(function() {
 $('.formTitle').css("display", "block");
$('.msgs').html(");
 $('input').not(':input[type=submit], :input[type=hidden]').val(");

 //your code

 }, 3000);
},
 error: function(jqXHR, text, error) {
message.html(error);
 formTitle.css("display", "none");
 setTimeout(function() {
 $('.formTitle').css("display", "block");
$('.msgs').html(");
 $('input').not(':input[type=submit], :input[type=hidden]').val(");
 }, 3000);
}
});
inst.close();
 return false;
 });
- Eloy commented on June 10th 19 at 14:54
Where is the comment //your code
In this place call the function close window inst.close() - jaeden33 commented on June 10th 19 at 14:57
Did
$(document).ready(function() {
 $("form").submit(function() {
 var formID = $(this).attr('id');
 var formNm = $('#' + formID);
 var message = $(formNm).find(".msgs");
 var formTitle = $(formNm).find(".formTitle");
$.ajax({
 type: "POST",
 url: 'https://site.ru/mail.php',
 data: formNm.serialize(),
 success: function(data) {
message.html(data);
 formTitle.css("display", "none");
 setTimeout(function() {
 $('.formTitle').css("display", "block");
$('.msgs').html(");
 $('input').not(':input[type=submit], :input[type=hidden]').val(");

 //your code

inst.close();
 }, 3000);
},
 error: function(jqXHR, text, error) {
message.html(error);
 formTitle.css("display", "none");
 setTimeout(function() {
 $('.formTitle').css("display", "block");
$('.msgs').html(");
 $('input').not(':input[type=submit], :input[type=hidden]').val(");
 }, 3000);
}
});
 return false;
});
 var $input = $('.form fieldset > input');
 $input.blur(function(e) {
 $(this).toggleClass('filled', !!$(this).val());
});
});

but it is inserted at the end of the html
var inst = $('[data-remodal-id=firstModal]').remodal();

But now all not dispatched. The window just clears all data and remains open. - Eloy commented on June 10th 19 at 15:00
Should all work.
Check on the real host not on the local machine.
Check if on LAN, it is likely that the query does not retrieve the information about the successful submission, and he accordingly does not success, and error
Can check it out. this function inst.close(); add the error

Well, for full details it is advisable to see what the console says after you submit the form.
Personally protestirovat your script, it works (but as he conducted test for LAN, I closed the window in error) - jaeden33 commented on June 10th 19 at 15:03
hmm, the test on the host, but not sent. Here try myself https://deep-webb.ru the first button is the order of the tour.. - Eloy commented on June 10th 19 at 15:06
to insert this code out the error message is successfully sent and sent and now just form being updated and all.Sending to soap not - Eloy commented on June 10th 19 at 15:09
question, and here
var inst = $('[data-remodal-id=firstModal]').remodal();
after the attribute data-remodal-id data must specify the form or leave modal? - Eloy commented on June 10th 19 at 15:12
var inst = $('[data-remodal-id=firstModal]').remodal();
Here is recorded the data modelki

About the website. Maybe I'm not careful, quickly looked through, but why it is not found the script processing the ajax - jaeden33 commented on June 10th 19 at 15:15
June 10th 19 at 14:44
he's in the vendor, so Assembly is configured galpa. No, the email is sent, it turns out, just with a big delay and now comes why it is nonsense..instead of the name and phone numbers, and so on, although in addition to the above edits did not made, and so it has
var inst = $('[data-remodal-id=firstModal]').remodal();
var inst = $('[data-remodal-id=firstModal]').remodal(); If modelka offer, all perfectly done.

To send the digits and other nonsense...
$(document).ready(function() {
 $("form").submit(function() {
 var formID = $(this).attr('id');
 var formNm = $('#' + formID);
 var message = $(formNm).find(".msgs");
 var formTitle = $(formNm).find(".formTitle");
$.ajax({
 type: "POST",
 url: 'https://site.ru/mail.php',
 data: formNm.serialize(),
 success: function(data) {
message.html(data);
 formTitle.css("display", "none");
 setTimeout(function() {
 $('.formTitle').css("display", "block");
$('.msgs').html(");
 $('input').not(':input[type=submit], :input[type=hidden]').val(");

 //your code

inst.close();
 }, 3000);
},
 error: function(jqXHR, text, error) {
message.html(error);
 formTitle.css("display", "none");
 setTimeout(function() {
 $('.formTitle').css("display", "block");
$('.msgs').html(");
 $('input').not(':input[type=submit], :input[type=hidden]').val(");
 }, 3000);
}
});
 return false;
});
 var $input = $('.form fieldset > input');
 $input.blur(function(e) {
 $(this).toggleClass('filled', !!$(this).val());
});
});


data: formNm.serialize() - it contains what goes in the mail. In principle, nothing complicated, if you understand a little bit. - Eloy commented on June 10th 19 at 14:47

Find more questions by tags CSSJavaScript