admin管理员组文章数量:1333645
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
1 Answer
Reset to default 4I 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.
本文标签: javascriptFlexslider Add Slide (Ajax Content)Stack Overflow
版权声明:本文标题:javascript - Flexslider Add Slide (Ajax Content) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742269563a2444046.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论