【问题标题】:how to stop clash between jquery and protoype on this page如何在此页面上停止 jquery 和原型之间的冲突
【发布时间】:2017-11-30 17:02:19
【问题描述】:

此页面是 magento 和 wordpress 主题的组合。不幸的是,jquery 导致原型无法工作,但我对使用开发人员工具来定位这类问题并不感到惊讶。 我的理解是我需要在 noConflict 模式下运行 jquery,但我找不到从 wordpress 主题中调用它的位置。 谁能告诉我如何找到这个或解决问题。 http://www.findcarpettiles.co.uk/wp/general-information/free-samples-measurement/ 谢谢

【问题讨论】:

    标签: javascript jquery wordpress magento


    【解决方案1】:

    jQuery 被包含并自动在 noConflict 模式下运行。我相信您的问题是您包含了两个版本的 jQuery(一个来自 Magento,一个来自 WP)。如果我是你,我会在你的 functions.php 中添加以下内容,以阻止 WP 包含其 jQuery 版本。

    add_filter( 'wp_default_scripts', 'change_default_jquery' );
    
    function change_default_jquery( &$scripts){
        if(!is_admin()){
            $scripts->remove( 'jquery');
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2012-01-15
      • 2014-06-21
      • 2014-09-24
      • 2010-09-13
      • 1970-01-01
      • 1970-01-01
      • 2011-03-08
      • 2010-11-01
      • 2012-01-09
      相关资源
      最近更新 更多