【发布时间】:2011-06-07 08:51:22
【问题描述】:
我正在将内容滑块集成到 magento 主题中,但 js 存在一些问题。 我收到错误“$ 未定义”,然后我从网站上找到了一个解决方案,说明我应该添加这一行“jQuery.noConflict();”进入我的 jquery 文件。
然后在home.phtml中,:-
<script type="text/javascript">
var $s = jQuery.noConflict();
$s(document).ready(function(){
$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
});
</script>
在我的 page.xml 中,这就是我包含 js 的方式
<action method="addJs"><script>jquery/jquery.js</script></action>
<action method="addJs"><script>jquery/jquery-ui.min.js</script></action>
<action method="addJs"><script>prototype/prototype.js</script></action>
完成上述更改后,我收到错误“未定义 jQuery”
感谢任何建议。提前致谢!
编辑: 这个问题是通过从CMS页面调用js来解决的->内容:-
<script type="text/javascript">// <![CDATA[
var $j = jQuery.noConflict(); jQuery(document).ready(function($) { jQuery("#featured ul").tabs({fx:{opacity:"toggle"}}).tabs("rotate", 5000, true); }); // >
// ]]></script>
在 CMS 页面 -> 设计,包含所需的 js 文件:-
<reference name="head">
<action method="addItem"><type>skin_css</type><name>css/slider.css</name></action>
<action method="addItem"><type>skin_js</type><name>js/jquery.min.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/jquery-ui.min.js</name></action>
</reference>
但是,这种方法只有在只有特定页面使用 js 而不是每个页面时才有用。 :)
【问题讨论】: