Javascript jQuery noconflict问题表明$(..)不是一个函数
我对js有问题,在它给出$(..)之后,cslide不是一个函数,我认为代码不支持jQuery noConflict 这是default.php代码Javascript jQuery noconflict问题表明$(..)不是一个函数,javascript,php,jquery,Javascript,Php,Jquery,我对js有问题,在它给出$(..)之后,cslide不是一个函数,我认为代码不支持jQuery noConflict 这是default.php代码 defined('_JEXEC') or die('Restricted access'); // no direct access JHTML::stylesheet('style.css', JURI::root() . 'modules/mod_slide_parallax/css/'); if (!JFactory::getAppl
defined('_JEXEC') or die('Restricted access'); // no direct access
JHTML::stylesheet('style.css', JURI::root() . 'modules/mod_slide_parallax/css/');
if (!JFactory::getApplication()->get('jquery')) {
JFactory::getApplication()->set('jquery', true);
JHTML::script('jquery.min.js', JURI::root() . 'modules/mod_jmsmegamenu/assets/jquery/');
}
$langScript = "(function($) {
$(document).ready(function($){
$('#da-slider1').cslider({
autoplay:" . ($rb_autoplay == 1 ? "true" : "false") . ",
interval: " . $txt_interval . ",
bgincrement: " . $txt_bgincrement . ",
navigation: " . ($rb_navigation == 1 ? "true" : "false") . "
});
})(jQuery);";
/*$langScript = "$(function($){\$('#da-slider1').cslider(
{
autoplay:" . ($rb_autoplay == 1 ? "true" : "false") . ",
interval: " . $txt_interval . ",
bgincrement: " . $txt_bgincrement . ",
navigation: " . ($rb_navigation == 1 ? "true" : "false") . "
}
); });";*/
$document = &JFactory::getDocument();
$document->addScriptDeclaration($langScript);
JHTML::script('jquery.cslider.js', JURI::root() . 'modules/mod_slide_parallax/js/');
JHTML::script('modernizr.custom.28468.js', JURI::root() . 'modules/mod_slide_parallax/js/');
?>
<div id="da-slider1" class="da-slider<?php echo $moduleclass_sfx; ?>">
<?php foreach ($list as $item) : ?>
<div class="da-slide">
<?php require JModuleHelper::getLayoutPath('mod_slide_parallax', '_item'); ?>
</div>
<?php endforeach; ?>
<!--<a class="da-arrows">
<?php if ($rb_arrows == 1): ?>
<span class="da-arrows-prev"></span>
<span class="da-arrows-next"></span>
<?php endif; ?>
</a>-->
</div>
但是错误仍然存在,我哪里做错了呢?只需将jQuery内容包装在匿名包装函数中,这样您就可以像平常一样使用$-速记:
jQuery(function($){
$('#da-slider1').cslider({
autoplay: $rb_autoplay == 1,
interval: $txt_interva,
bgincrement: $txt_bgincrement,
navigation: $rb_navigation == 1
});
请在节中包含最新的jquery库文件 还可以使用var j=jQuery.noConflict();在代码中,使用j作为脚本的别名 你可以
有时一些插件在其代码中使用$作为函数,如果使用了,则可能与jquery$别名和函数$发生冲突,因此在这种情况下,您必须更改$别名。我猜您的“cslide”插件在noConflict模式下不起作用。是的,这也是我的想法。有什么解决办法吗?你能给我们看一下cslide的代码吗?@jantimon我刚刚上传了cslide.js和default.php代码你当前的错误消息是什么?或者它的缩写:
jQuery(function($){
$langScript = "jQuery(document).ready(function($){
//you can now use $ as your jQuery object.
jQuery('#da-slider1').cslider(
{
autoplay:" . ($rb_autoplay == 1 ? "true" : "false") . ",
interval: " . $txt_interval . ",
bgincrement: " . $txt_bgincrement . ",
navigation: " . ($rb_navigation == 1 ? "true" : "false") . "
}
);
});";
jQuery(function($){
$('#da-slider1').cslider({
autoplay: $rb_autoplay == 1,
interval: $txt_interva,
bgincrement: $txt_bgincrement,
navigation: $rb_navigation == 1
});