Hi there,
I came across a problem that I seriously don’t know how solve. For a project I implemented a form with the help of Kirby Uniform Plugin. Validation takes place with another jQuery Plugin called JQuery Form Validator. The Form gets sended via AJAX. I simply want to reset the form and Make it possible to send another Mail without reloading the page.
This is how my JS looks:
$("#contact-form").submit(function(e) {
e.preventDefault();
var $this = $(this),
actionurl = e.currentTarget.action,
formData = $this.serialize();
$.ajax({
type:'post',
url: actionurl,
data: formData,
beforeSend:function(){
// launchpreloader();
},
complete:function(){
$this.fadeOut(300, function(){
$('.content--contact').scrollTop(0);
});
},
success:function(result){
$('.form--completed').delay(500).fadeIn(300);
}
});
});
The Page controller looks like that:
<?php
use Uniform\Form;
return function ($site, $pages, $page)
{
$form = new Form([
'name' => [],
'company' => [],
'email' => [],
'phone' => [],
'message' => [],
'checkbox' => []
]);
if (r::is('POST')) {
$form->emailAction([
'to' => '.......@gmail.com',
'from' => 'noreply@.......de',
'subject' => 'TEST',
'snippet' => 'emails/success',
]);
}
return compact('form');
};
var resetForm = function(e, delay){
var me = $(e);
if(me.css('display') == 'none'){
setTimeout(function(){
// RESET FORM
me[0].reset();
// DISABLE SUBMIT BUTTON
me.find("input[type=submit]").prop("disabled", true).addClass("disabled");
// HIDE THE SUBMIT CONFIRMATION
me.next().hide();
// SHOW THE FORM AGAIN
me.show();
}, delay);
}
}
After the submitting the form I am calling the resetForm Function. And everything works fine, except that the second Mail never gets sended. Can anybody help?