在加载Ajax内容时初始化Visual Composer [英] Initializing Visual Composer upon Ajax content load

查看:141
本文介绍了在加载Ajax内容时初始化Visual Composer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的基本结构,有一个ajax脚本,用于替换div内部内容并更新菜单,推送历史记录状态,淡入/淡出内容等.

Basic Structure below, have an ajax script that replaces the div inner-content and updates the menu, pushes history states, fade in/out contents ect..

内部内容包含一个基础网格行,而wordpress编辑器的内容位于该容器中.

The inner-content contains a foundation grid row and content of wordpress editor lives inside that container.

现在是问题所在……当使用需要JavaScript触发器,全宽跨度,滑块,动画的任何Visual composer函数时,当我的ajax函数触发内容替换时,什么也不会再次加载.

Now here is the issue... when using any Visual composer function that requires javascript triggers, Full width Span, slider, animations nothing gets loaded again when my ajax function triggers a content replace.

这是我的代码的一部分,在ajax获得内容之后加载.

Here is part of my code that loads after ajax have got the content.

// Update the content
$content.stop(true,true);
//$("[data-vc-grid-settings]").vcGrid();
$('#content').foundation();
$content.html(contentHtml).ajaxify().css('opacity',100).show(); /* you could fade in here if you'd like */

// Update the title
document.title = $data.find('.document-title:first').text();

我认为.vcGrid()是正确的init,但是出现了未定义的控制台错误. 在哪里可以找到与重新初始化Visual Composer元素有关的文档?

I thought .vcGrid() was the right init, but got the not defined console error. Where can I find docs related to re-initializing the visual composer elements?

<html>
<header>
Meta Content
</header>
<div off-canvus>
   <menu></menu>
   <div content>
      <div inner-content>

      </div>
   </div>
   <footer>
   </footer>
   <scripts>
</html>

推荐答案

在通过可视化作曲家的javascript进行挖掘后找到了我需要的数据,为窗口添加了一个调整大小的动作,该操作触发了可视化作曲家的网格正常工作.

Found the data I needed after digging through visual composer's javascript, added a resize action for window which triggers the visual composer's grid to work correctly.

$content.stop(true,true);
window.vc_js();
window.resize();
$('#content').foundation();
$content.html(contentHtml).ajaxify().css('opacity',100).show(); /* you could fade in here if you'd like */

// Update the title
document.title = $data.find('.document-title:first').text();
try {
    document.getElementsByTagName('title')[0].innerHTML = document.title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');
}
catch ( Exception ) { }

这篇关于在加载Ajax内容时初始化Visual Composer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆