我在joomla 2.5模板上使用jquery时遇到了一些问题。如果没有Joomla,我的jquery脚本(rcarouser)可以正常工作。这是我的index.html,而不是Joomla!模板(连接js脚本):
<script type="text/javascript" src="widget/lib/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="widget/lib/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="widget/lib/jquery.ui.widget.min.js"></script>
<script type="text/javascript" src="widget/lib/jquery.ui.rcarousel.min.js"></script>
<script type="text/javascript" src="scripts.js"></script>
<link type="text/css" rel="stylesheet" href="widget/css/rcarousel.css" />
这是scripts.js:中的脚本
jQuery(function($) {
$( "#carousel" ).rcarousel({width: 235, height: 170, visible: 4, step: 4, margin: 5,
auto: {enabled: true, direction: "next", interval: 5000},
navigation: {prev: "#ui-carousel-prev",next: "#ui-carousel-next" } } );
$( ".image_slider_right_ex" ).rcarousel({width: 185, height: 160, visible: 5, step: 5, margin: 5,
auto: {enabled: true, direction: "next", interval: 5000}, orientation: "vertical",
navigation: {prev: ".slider_right_arrow_down_link",next: ".slider_right_arrow_top_link" }
});
$( "#carousel_laredo" ).rcarousel({width: 320, height: 148, visible: 3, step: 3,
auto: {enabled: true, direction: "next", interval: 5000},
navigation: {prev: "#slider_button_left_laredo_link",next: "#slider_button_right_laredo_link" }
});
$( ".image_slider_right_laredo_ex" ).rcarousel({width: 210, height: 255, visible: 4, step: 4, margin: 5,
auto: {enabled: true, direction: "next", interval: 5000}, orientation: "vertical",
navigation: {prev: ".slider_button_right_laredo_link",next: ".slider_button_left_laredo_link" }
});
$( "#image_gallery_canter_element" ).rcarousel({width: 210, height: 255, visible: 3, step: 1, margin: 2,
navigation: {prev: "#gallery_button_left",next: "#gallery_button_right"}
});
});
这是我在Joomla连接脚本!:
$doc = JFactory::getDocument();
$doc->addScript($this->baseurl.'/templates/'.$this->template.'/javascript /scripts.js', 'text/javascript');
$doc->addScript($this->baseurl.'/templates/'.$this->template.'/javascript/lib/jquery.ui.core.min.js', 'text/javascript');
$doc->addScript($this->baseurl.'/templates/'.$this->template.'/javascript/lib/jquery.ui.widget.min.js', 'text/javascript');
$doc->addScript($this->baseurl.'/templates/'.$this->template.'/javascript/jquery.ui.rcarousel.min.js', 'text/javascript');
我安装了简单的jquery插件。但我有错误:
TypeError: $(...).rcarousel is not a function
它有相同的源代码,也就是说它连接了jquery脚本。但我不明白为什么它不起作用。请帮帮我。
我认为,您的问题是由jquery mootools冲突引起的(它们都使用$)该问题在以下问题中进行了讨论:如何修复Joomla aiContactSafe 上的Mootools和jQuery冲突