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
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.com/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.
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 commenting out that whole if statement and it started working when I only had one slide.