未捕获的类型错误:jQuery 不是一个函数



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

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 主题的无冲突.js文件中可能的那样,已经有一个实现。

更新:这是被投诉的应用程序.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');
}
});

编辑来自凯文的帖子评论...

改变

jQuery(...)

$j(...)

相关内容

  • 没有找到相关文章

最新更新