Uncaught TypeError: jQuery is not a function

Uncaught TypeError: jQuery is not a function

是的,我进行了研究,据我所知,到目前为止我无法弄清楚为什么产品标签似乎无处不在,不再按预期运行。在控制台中,我看到:

app.js:932 Uncaught TypeError: jQuery is not a function

我们在从 Magento 1.9.3.3(ish) 更新到 1.9.3.6(现在是 1.9.3.8)后注意到了这一点。我们使用 RWD 主题作为父主题,并在其之上有一个自定义主题。有两个 jQuery 库,但如果我拿走 jQuery 1.11.0.min.js 产品页面布局的部分内容就会消失。

如果你能帮助我解决这个奇怪的情况,我将不胜感激。

以下是加载时的所有脚本:

<link rel="stylesheet" type="text/css" href="<removed>/skin/frontend/base/default/css/nwdthemes/ultratabs_base_default.css" media="all" />
<script type="text/javascript" src="<removed>/js/prototype/prototype.js"></script>
<script type="text/javascript" src="<removed>/js/lib/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="<removed>/js/lib/jquery/noconflict.js"></script>
<script type="text/javascript" src="<removed>/js/lib/ccard.js"></script>
<script type="text/javascript" src="<removed>/js/prototype/validation.js"></script>
<script type="text/javascript" src="<removed>/js/scriptaculous/builder.js"></script>
<script type="text/javascript" src="<removed>/js/scriptaculous/effects.js"></script>
<script type="text/javascript" src="<removed>/js/scriptaculous/dragdrop.js"></script>
<script type="text/javascript" src="<removed>/js/scriptaculous/controls.js"></script>
<script type="text/javascript" src="<removed>/js/scriptaculous/slider.js"></script>
<script type="text/javascript" src="<removed>/js/varien/js.js"></script>
<script type="text/javascript" src="<removed>/js/varien/form.js"></script>
<script type="text/javascript" src="<removed>/js/mage/translate.js"></script>
<script type="text/javascript" src="<removed>/js/mage/cookies.js"></script>
<script type="text/javascript" src="<removed>/js/calendar/calendar.js"></script>
<script type="text/javascript" src="<removed>/js/calendar/calendar-setup.js"></script>
<script type="text/javascript" src="<removed>/js/varien/product.js"></script>
<script type="text/javascript" src="<removed>/js/varien/product_options.js"></script>
<script type="text/javascript" src="<removed>/js/varien/configurable.js"></script>
<script type="text/javascript" src="<removed>/js/video/video.js"></script>
<script type="text/javascript" src="<removed>/js/video/jquery.fitvids.js"></script>
<script type="text/javascript" src="<removed>/js/video/masonry.js"></script>
<script type="text/javascript" src="<removed>/js/video/html5lightbox.js"></script>
<script type="text/javascript" src="<removed>/js/video/owl.carousel.min.js"></script>
<script type="text/javascript" src="<removed>/js/fileuploader/filepop.js"></script>
<script type="text/javascript" src="<removed>/js/nwdthemes/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="<removed>/js/nwdthemes/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="<removed>/js/nwdthemes/jquery.noconflict.js"></script>
<script type="text/javascript" src="<removed>/js/nwdthemes/matchMedia.js"></script>
<script type="text/javascript" src="<removed>/js/nwdthemes/matchMedia.addListener.js"></script>
<script type="text/javascript" src="<removed>/js/nwdthemes/enquire.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/rwd/default/js/lib/modernizr.custom.min.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/rwd/default/js/lib/selectivizr.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/rwd/default/js/lib/matchMedia.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/rwd/default/js/lib/matchMedia.addListener.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/rwd/default/js/lib/enquire.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/rwd/default/js/app.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/rwd/default/js/lib/imagesloaded.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/rwd/default/js/minicart.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/<removed>2/default/js/readmore.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/base/default/js/et_advancedcompare/noreload.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/base/default/magehit_bestseller/js/noconflict.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/base/default/magehit_bestseller/js/owl.carousel.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/base/default/magehit_newproducts/js/noconflict.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/base/default/magehit_newproducts/js/owl.carousel.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/base/default/js/flexibleblog/general.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/base/default/js/flexibleforms/jquery-noconflict.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/base/default/js/flexibleforms/stars.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/<removed>2/default/js/image-hijacker.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/rwd/default/js/lib/elevatezoom/jquery.elevateZoom-3.0.8.min.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/base/default/nwdthemes/revslider/public/assets/js/jquery.themepunch.tools.min.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/base/default/nwdthemes/revslider/public/assets/js/jquery.themepunch.revolution.min.js"></script>
<script type="text/javascript" src="<removed>/skin/frontend/base/default/js/nwdthemes/ultratabs.js"></script>
<link rel="stylesheet" href="//opensource.keycdn.com/fontawesome/4.6.3/font-awesome.min.css" />

此外,我找到的很多针对其他类似问题的解决方案都要求将“$”替换为“$j”,但正如您现在可能在 RWD 主题的 no-confict.js 文件中那样已经实现了。

更新: 这是 app.js(RWD 主题)中被抱怨的代码。我在出错的行之前添加了注释。我对如何解决这个问题感到很困惑。

// ==============================================
// UI Pattern - Toggle Content (tabs and accordions in one setup)
// ==============================================

$j('.toggle-content').each(function () {
    var wrapper = jQuery(this);

    var hasTabs = wrapper.hasClass('tabs');
    var hasAccordion = wrapper.hasClass('accordion');
    var startOpen = wrapper.hasClass('open');

    var dl = wrapper.children('dl:first');
    var dts = dl.children('dt');
    var panes = dl.children('dd');
    var groups = new Array(dts, panes);

    //Create a ul for tabs if necessary.
    if (hasTabs) {
        var ul = jQuery('<ul class="toggle-tabs"></ul>');
        dts.each(function () {
            var dt = jQuery(this);
            var li = jQuery('<li></li>');
            li.html(dt.html());
            ul.append(li);
        });
        ul.insertBefore(dl);
        var lis = ul.children();
        groups.push(lis);
    }

    //Add "last" classes.
    var i;
    for (i = 0; i < groups.length; i++) {
        groups[i].filter(':last').addClass('last');
    }

    function toggleClasses(clickedItem, group) {
        var index = group.index(clickedItem);
        var i;
        for (i = 0; i < groups.length; i++) {
            groups[i].removeClass('current');
            groups[i].eq(index).addClass('current');
        }
    }

    //Toggle on tab (dt) click.
    dts.on('click', function (e) {
        //They clicked the current dt to close it. Restore the wrapper to unclicked state.
        if (jQuery(this).hasClass('current') && wrapper.hasClass('accordion-open')) {
            wrapper.removeClass('accordion-open');
        } else {
            //They're clicking something new. Reflect the explicit user interaction.
            wrapper.addClass('accordion-open');
        }
        toggleClasses(jQuery(this), dts);
    });

    //Toggle on tab (li) click.
    if (hasTabs) {
        lis.on('click', function (e) {
//This line here is where it errors.
            toggleClasses(jQuery(this), lis);
        });
        //Open the first tab.
        lis.eq(0).trigger('click');
    }

    //Open the first accordion if desired.
    if (startOpen) {
        dts.eq(0).trigger('click');
    }

});

编辑 post 来自凯文的评论...

改变

jQuery(...)

$j(...)