未捕获的TypeError:jQuery不是一个函数

时间:2018-05-18 03:15:35

标签: javascript jquery magento magento-1.9

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

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');
    }

});

1 个答案:

答案 0 :(得分:0)

编辑发表评论来自凯文......

更改

jQuery(...)

$j(...)