1
我试图在我的wordpress网站上使用smoothstate.js实现联系表格7。当使用该页面的页面直接加载时,联系表单可以很好地工作。但是,如果通过AJAX加载页面,则会显示错误“wpcf7.initForm不是函数”。通过AJAX(smoothstate.js)加载页面时,联系表格7引发'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");
});