Я пытаюсь реализовать контактную форму 7 на своем веб-сайте WordPress с помощью smoothstate.js. Контактная форма отлично работает, когда страница, на которой она используется, загружается напрямую. Однако, если страница загружается через AJAX, появляется ошибка «wpcf7.initForm не является функцией».
Я не гений с AJAX, но моя мысль состояла в том, чтобы повторно инициализировать функцию AJAX onAfter. Я попробовал это, используя wpcf7InitForm(); но все равно не повезло.
Любая помощь по этой теме будет принята с благодарностью!
Вот мой текущий код AJAX:
//SmoothState Page Transitions
$(function(){
'use strict';
var $page = $('#main'),
options = {
debug: true,
prefetch: true,
onStart: {
duration: 800, // Duration of our animation
render: function ($container) {
// Add your CSS animation reversing class
$container.addClass('is-exiting');
// Restart your animation
smoothState.restartCSSAnimations();
}
},
onReady: {
duration: 0,
render: function($container, $newContent) {
// Remove your CSS animation reversing class
$container.addClass('is-loaded');
setTimeout(function(){
$container.addClass('unload');
}, 600);
setTimeout(function(){
$container.removeClass('is-loaded unload');
}, 900);
// Inject the new content
$container.html($newContent);
}
},
onAfter: function($container) {
$container.removeClass('is-exiting');
$('div.wpcf7 > form').wpcf7InitForm();
$(window).data('plugin_stellar').refresh();
}
},
smoothState = $("#main").smoothState(options).data("smoothState");
});