使用 jQuery 滑块时,下拉菜单在 Magento 中不起作用

发布于 2024-11-26 16:54:59 字数 540 浏览 4 评论 0原文

在主页上使用 jQuery 滑块时,我在 Magento 中显示下拉菜单时遇到问题。 (在所有其他页面上正常显示)

我对这一切都很陌生,但据我了解,它与 Magentos 原型库发生冲突。但到目前为止,我在网上找到的任何指南都没有解决这个问题。

我在导入脚本时使用谷歌托管版本,并将它们导入到 HTML 正文中,以便它们仅加载到需要它们的首页上。

我已经尝试添加 到 head.phtml 或实际脚本中,用 jQuery 替换 $,自行托管它并添加 skin_jsjs/jquery.js 在 page.xml 布局文件中......

以及我到目前为止所做的一切没有起作用。它要么没有修复导航,要么修复了导航但使滑块崩溃。

有什么线索吗?预先感谢您的帮助。

I have a problem with getting dropdown menu to appear in Magento when using jQuery slider on home page. (displays normally on all other pages)

I'm very much new to all this but from what i understand its clashing with Magentos Prototype library. But so far any guides i was able to find online haven't fixed the issue.

I'm using the google hosted version when importing scripts, and i import them in the HTML body so they only load on the front page where they are needed.

I have already tried adding <script type="text/javascript">
jQuery.noConflict();
</script>
to head.phtml or in the actual script, replacing the $ with jQuery, self hosting it and adding <action method="addItem"><type>skin_js</type><name>js/jquery.js</name></action> in the page.xml layout file...

... and everything i've done so far hasn't worked. It either didn't fix the navigation or it fixed the navigation but crashed the slider.

Any clues? Thanks in advance for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

笑着哭最痛 2024-12-03 16:54:59

正如这里提醒的那样,我为解决问题所做的工作是:

var j$ = jQuery.noConflict();

在启动脚本之前添加此内容,就在标记之后,然后在代码中使用 j$ 而不是 $。现在可以工作了:)

Just as a heads up here is what i did to fix the problem:

var j$ = jQuery.noConflict();

added this before starting the script, right after the tag, and then just used j$ instead of $ in the code. Works now :)

请你别敷衍 2024-12-03 16:54:59

就我而言,jquery.jsslider.js 是在 getChildHtml('head') 之后调用的。我移动了它,这样他们之前就会被调用,现在工作正常。无论冲突是什么,都不再是问题了。现在下拉菜单会下降并且滑块会滑动。

In my case, the jquery.js and slider.js were being called AFTER getChildHtml('head'). I moved it so they would be called before and now it is working OK. Whatever the conflict was, it is not an issue anymore. Now the dropdowns drop and the slider slides.

韵柒 2024-12-03 16:54:59

尝试使用 firebug 并查看在大多数情况下您遇到的错误是由冲突引起的,如果您使用了 jQuery.noConflict() 它应该可以工作,并确保您将 jQuery.noConflict() 包装在 jQuery 的 document.ready 函数中。

Try using firebug and see what error you are getting in most cases it is caused by the conflict if you have used jQuery.noConflict() it should work and make sure you wrap your jQuery.noConflict() in document.ready function of jQuery.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文