简体   繁体   English

$(...)。flexlexlider不是函数错误

[英]$(…).flexslider is not a function error

I'm developing a Joomla 3 template using the T3 Framework and I've included an IceCarousel module which uses the Flexslider plugin. 我正在使用T3 Framework开发一个Joomla 3模板,并且我已经包含了一个使用Flexslider插件的IceCarousel模块。 However, the IceCarousel module isn't working because there is a javascript error that says: 但是, IceCarousel模块无法正常工作,因为有一个javascript错误说:

$(...).flexslider is not a function
Line 477

I've taken a look at the page source and the flexslider source files are definitely there. 我已经看了一下页面源代码,flexslider源代码文件肯定存在。 There is also a /media/jui/jquery-noconflict.js file which comes standard with Joomla 3. I am not sure if this is what is causing the problem. 还有一个/media/jui/jquery-noconflict.js文件,它是Joomla 3的标准配置。我不确定这是否是造成问题的原因。 Is this an issue of the order of the stacking of the javascript files? 这是javascript文件堆叠顺序的问题吗?

http://www.veterantrainingsymposium.com/2014-home-page http://www.veterantrainingsymposium.com/2014-home-page

You have defined the jquery two times. 您已经定义了两次jquery。 remove one jquery http://gyazo.com/c784a654eefe6e1b6ac061e562f3f051 删除一个jquery http://gyazo.com/c784a654eefe6e1b6ac061e562f3f051

Try simplifying your code to test if there is a timing issue, eg: 尝试简化代码以测试是否存在计时问题,例如:

$(document).ready(function() {
$('#icecarousel119').flexslider({
    selector: ".slides > div", 
    animation: "slide",
    direction: "horizontal",
    itemWidth:90,
    slideshowSpeed:5000, 
    animationspeed:600,  
    itemMargin:0,
    minItems:1,
    maxItems:0, 
    move: 0,    

            slideshow: false,

            directionNav: true,

            controlNav: true,

    start: function(slider){
      $('body').removeClass('loading');
    }
  });
});

}); });

Also, flexslider examples use class, not id (though I don't think this is causing the issue) 另外,flexslider示例使用class,而不是id(虽然我不认为这会导致问题)

I was faced the same problem and fixed it. 我遇到了同样的问题并修复了它。 I have used only one instance of jquery.js file, but still was getting the same problem. 我只使用了jquery.js文件的一个实例,但仍然遇到了同样的问题。

After self investigating finally I got the issue and fix it,keep in mind do not use defer or async keyword in below 2 files: 自我调查后,我得到了问题并修复它,请记住不要在下面的2个文件中使用defer或async关键字:

1- jquery.flexslider-min.js 1- jquery.flexslider-min.js

2- jquery.prettyPhoto.js 2- jquery.prettyPhoto.js

I was using a WordPress plugin (Meta-Slider) and it did not include the Jquery Flexslider module. 我使用的是WordPress插件(Meta-Slider),它不包含Jquery Flexslider模块。

Downloaded from here: https://github.com/woocommerce/FlexSlider 从这里下载: https//github.com/woocommerce/FlexSlider

Added to my project, added to my header after a normal Jquery... 添加到我的项目中,在正常的Jquery之后添加到我的标题中...

    <script src="<?php echo get_bloginfo('template_directory'); ?>/js/jquery-3.2.1.min.js"></script>
    <script src="<?php echo get_bloginfo('template_directory'); ?>/js/jquery.flexslider-min.js"></script>

Then got rid of some other buggy JS code that came after and it's working. 然后摆脱了之后发生的一些其他有缺陷的JS代码,它正在运行。

For people using Wordpress and getting this error: 对于使用Wordpress并收到此错误的人:

Make sure that the link to the FlexSlider js ( ie: <script defer src="<?php bloginfo('template_url'); ?>/js/jquery.flexslider-min.js"></script> ) is below <?php wp_head(); ?> 确保指向FlexSlider js的链接(即: <script defer src="<?php bloginfo('template_url'); ?>/js/jquery.flexslider-min.js"></script> )在<?php wp_head(); ?> <?php wp_head(); ?>

This is applicable to loading script in the header.php file. 这适用于在header.php文件中加载脚本。 Better practice would be to load all js in the footer, but there may be instances when you don't have control over that. 更好的做法是将所有j加载到页脚中,但可能存在无法控制的情况。

Hope this helps someone else as it helped me :) 希望这可以帮助别人,因为它帮助了我:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM