I'm using the Octomail plug-in to handle some contact forms on a site.
The site is using Foundation rather Bootstrap so the forms are set-up with custom HTML. I also don't use the default error handling for form validation as this just throws up an alert box with the relevant error message. Thus, instead of using the data-attributes on the form, I am using the Javascript API as per the docs so that I can override the default behaviour (http://octobercms.com/docs/cms/ajax#javascript-api).
Everything works fine apart from the fact that Ajax loader (the bar the loads across the page) is not triggered when using the Javascript API. It works fine using the data-attributes.
Relevant code snippets below: The form:
<form role="form" onsubmit="$(this).request('{{ __SELF__ }}::onOctoMailSent',
{success: function(){
showSuccess()
},
error: function(jqXHR) {
showErrors(jqXHR.responseJSON)
}
}); return false;
">
<!-- field definitions -->
</form>
and the JS functions called by the form:
function showErrors(errs) {
$.each(errs.X_OCTOBER_ERROR_FIELDS,function(idx, val){
$('#' + idx).addClass('error').next('small.error').text(val).css('display','block');
})
$('.alert-box.warning').show();
}
function showSuccess() {
$('.alert-box.success').show();
setTimeout(function(){
$('.alert-box.success').close();
}, 5000);
$('#name').val('');
$('#email').val('');
$('#phone').val('');
$('#subject').val('');
$('#body').val('');
}
Has anybody experienced similar when using the Javascript API to trigger events or does anyone know what I can call to trigger the ajax loader manually?
Last updated