Skip to content

Instantly share code, notes, and snippets.

@Sentinel-7
Last active June 1, 2024 00:47
Show Gist options
  • Save Sentinel-7/1a93cf7739d5e14456499a2417bee770 to your computer and use it in GitHub Desktop.
Save Sentinel-7/1a93cf7739d5e14456499a2417bee770 to your computer and use it in GitHub Desktop.
AjaxForm закрытие окна после отправки + fancybox
<script>
$(document).ready(function() {
AjaxForm.Message.success = function() {};
});
$(document).on('af_complete', function(event,res) {
if(res.success) $('.fancybox-close-small').click();
if (res.success) {
// показываем сообщение об успехе
$.fancybox.close();
$.fancybox.open($('#thanks'), {
autoSize: true,
padding: 0,
closeBtn: false,
helpers: {
overlay: {locked: false, closeClick: true}
}
});
} else {
// закрывать ничего не надо, ибо ошибка и юзер должен её исправлять
}
});
$(document).on('af_complete', function(event, response) {
if (response.success) {
$('#callBackModal').modal('hide');
Swal.fire("Спасибо за обращение.", "Мы свяжемся с вами в ближайшее время.", "success");
}
response.message='';
} );
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment