使用 jQuery 滑块时,下拉菜单在 Magento 中不起作用
在主页上使用 jQuery 滑块时,我在 Magento 中显示下拉菜单时遇到问题。 (在所有其他页面上正常显示)
我对这一切都很陌生,但据我了解,它与 Magentos 原型库发生冲突。但到目前为止,我在网上找到的任何指南都没有解决这个问题。
我在导入脚本时使用谷歌托管版本,并将它们导入到 HTML 正文中,以便它们仅加载到需要它们的首页上。
我已经尝试添加 到 head.phtml 或实际脚本中,用 jQuery 替换 $,自行托管它并添加
在 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">
to head.phtml or in the actual script, replacing the $ with jQuery, self hosting it and adding
jQuery.noConflict();
</script><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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如这里提醒的那样,我为解决问题所做的工作是:
在启动脚本之前添加此内容,就在标记之后,然后在代码中使用 j$ 而不是 $。现在可以工作了:)
Just as a heads up here is what i did to fix the problem:
added this before starting the script, right after the tag, and then just used j$ instead of $ in the code. Works now :)
就我而言,
jquery.js
和slider.js
是在getChildHtml('head')
之后调用的。我移动了它,这样他们之前就会被调用,现在工作正常。无论冲突是什么,都不再是问题了。现在下拉菜单会下降并且滑块会滑动。In my case, the
jquery.js
andslider.js
were being called AFTERgetChildHtml('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.尝试使用 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.