local-host 2015-05-28 14:43 采纳率: 100%
浏览 3

Ajax和Fancybox

I'm using an Ajaxify plugin with Wordpress and I'm trying to get fancybox (or any lightbox script!) to load when an image is clicked. The fancybox plugin works fine without using the Ajaxify plugin but doesn't load at all with the Ajaxify plugin enabled. I'm guessing I've got to somehow recall the script but I'm not too sure how to go about this. I did try to add a 'no-axify' class to the fancybox link but to no avail:

jQuery('.fancybox').each(function(){
    jQuery(this).addClass('no-ajaxy');
});

I even purchased the Pro version which is less functional than the free version and the support hasn;t helped either.

Any ideas will be much appreciated!

  • 写回答

1条回答 默认 最新

  • weixin_33720452 2015-05-28 15:04
    关注

    in the function.php, add this code: (make sure the action priority should be less than 10. I used 9.)

    add_action('wp_enqueue_scripts', 'my_test_function', 9);
    function my_test_function(){
        wp_enqueue_script( 'my-script', get_template_directory_uri() . '/js/mine.js', array( 'jquery' ));
    }
    

    the /js/mine.js has simple code.

    jQuery(document).ready(function($) {
        $('.fancybox').addClass('no-ajaxy');
    });
    

    so, once you view source of your site, the mine.js should be included before the ajaxify.js

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测