私はsmoothstate.jsを使用してWordPressのWebサイトでContact Form 7を実装しようとしています。接触フォームは、それが使用されているページが直接ロードされたときに完全に機能します。ただし、ページがAJAX経由で読み込まれている場合、 'wpcf7.initForm is not a function'というエラーが表示されます。お問い合わせフォーム7 throws 'wpcf7.initFormは関数ではありません。' AJAX(smoothstate.js)を介してページを読み込む際のエラー
私は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");
});