javascript - Flexslider Add Slide (Ajax Content) - Stack Overflow

I'm writing a page where have a 4 slides with a of lot image content. To improve loading speed we

I'm writing a page where have a 4 slides with a of lot image content. To improve loading speed we want to only load the first slide. Then after its loaded we would get the rest through ajax calls and add them as slides.

Flexslider V2 has an .addSlide function for this, however I keep getting slider.addSlide is not a function error.

Any help would be much appreciated. Thanks

Flexslider

Here's my code.

<!DOCTYPE html>
<html lang="en">
<head>

<link rel="stylesheet" href="_slider/flexslider.css" type="text/css" />
<script src=".7.2/jquery.min.js"></script> 
<script src="_slider/jquery.flexslider-v2-min.js"></script>

<script type="text/javascript">
$(window).load(function() {
     $('.flexslider').flexslider({

        animation: "slide", 
        slideshow: false, 
        controlNav: false, 
        controlsContainer: ".flex_wrap", 
        start: function(slider){

            //Load another slide and append it to the html
            $.get('landing_page_step1.html', function(data) {
              $('.slides').append(data);
            });

            //Tell flexslider to add this as a slide
            slider.addSlide(".step1", 1);     
        }

      });
 });    
</script>

</head>

<body class="landing_page">

<div class="flex_wrap">
  <div class="flexslider grid_12">
    <ul class="slides">
      <li>
              Slide One
      </li>
    </ul>
 </div>
</div>

</body>
</html>

[Update]

Its appears that if you only have one slide then flexsider doesn't accept these extra functions. By starting with two slides this idea works fine. It's most likely an error or intended feature of flexslider.

I'm writing a page where have a 4 slides with a of lot image content. To improve loading speed we want to only load the first slide. Then after its loaded we would get the rest through ajax calls and add them as slides.

Flexslider V2 has an .addSlide function for this, however I keep getting slider.addSlide is not a function error.

Any help would be much appreciated. Thanks

Flexslider

Here's my code.

<!DOCTYPE html>
<html lang="en">
<head>

<link rel="stylesheet" href="_slider/flexslider.css" type="text/css" />
<script src="https://ajax.googleapis./ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
<script src="_slider/jquery.flexslider-v2-min.js"></script>

<script type="text/javascript">
$(window).load(function() {
     $('.flexslider').flexslider({

        animation: "slide", 
        slideshow: false, 
        controlNav: false, 
        controlsContainer: ".flex_wrap", 
        start: function(slider){

            //Load another slide and append it to the html
            $.get('landing_page_step1.html', function(data) {
              $('.slides').append(data);
            });

            //Tell flexslider to add this as a slide
            slider.addSlide(".step1", 1);     
        }

      });
 });    
</script>

</head>

<body class="landing_page">

<div class="flex_wrap">
  <div class="flexslider grid_12">
    <ul class="slides">
      <li>
              Slide One
      </li>
    </ul>
 </div>
</div>

</body>
</html>

[Update]

Its appears that if you only have one slide then flexsider doesn't accept these extra functions. By starting with two slides this idea works fine. It's most likely an error or intended feature of flexslider.

Share Improve this question edited Jul 11, 2012 at 17:39 dciso asked Jul 11, 2012 at 14:48 dcisodciso 1,2643 gold badges18 silver badges31 bronze badges 1
  • allowOneSlide is a property in v2.2+, see: github./woothemes/FlexSlider#allowoneslide-new – Keanan Koppenhaver Commented Jan 15, 2015 at 6:53
Add a ment  | 

1 Answer 1

Reset to default 4

I ran into this same issue just recently and I ended up looking at the source code and saw that the developers put in a check if the number of slides equals one (Line 882).

I just ended up menting out that whole if statement and it started working when I only had one slide.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742269564a4412441.html

相关推荐

  • javascript - Flexslider Add Slide (Ajax Content) - Stack Overflow

    I'm writing a page where have a 4 slides with a of lot image content. To improve loading speed we

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信