Woothemes Flexslider - one unique flexslider inside another flexslider - is it posible?

回眸只為那壹抹淺笑 提交于 2019-12-12 09:59:16

问题


I am using the newest flexslider from Woothemes, and I am trying to init one flexslider inside another. Like this:

function initFrontpageSliders() {

    $('#flexsliderFrontpage01').flexslider({
        animation: "slide",
        animationLoop: false,
        pauseOnHover: true,

        start: function(slider) {

            //Fires when the slider loads the first slide
            $('#flexsliderFrontpage02').flexslider({
                animation: "fade",
                directionNav: false,
                animationLoop: false,
                pauseOnHover: true  
            });


        }   
    });
}       

but when I call the script, is generates flexsliderFrontpage02 ul below flexsliderFrontpage01 and not inside the slide (list element) - like this:

<div id="flexsliderFrontpage01" class="flexslider">
    <div class="flex-viewport">

      <ul class="slides">
        <li>
          <div class="row">
             <div id="flexsliderFrontpage02" class="flexslider"> SLIDES SHOULD BE HERE </div>
          </div>
        </li>
        <li>
          <div class="row">slide 2</div>
        </li>  
      </ul>  

      <ul class="slides">
        <li><div class="row">fade 1</div></li>
        <li><div class="row">fade 2</div></li>
        <li><div class="row">fade 3</div></li>  
      </ul> 
   </div>

   <ol class="flex-control-nav flex-control-paging">
     <li>1</li>
     <li>2</li>
     <li>3</li>
     <li>4</li>
     <li>5</li>
   </ol>

   <ul class="flex-direction-nav"> </ul>
</div>

Do any of you know if theres an easy fix to flexslider.js or am I doing something wrong ? :-)

my HTML looks like this:

<div class="flexslider" id="flexsliderFrontpage01">
<ul class="slides">
    <li>
        <div class="row">
            <div class="flexslider" id="flexsliderFrontpage02">
                <ul class="slides">
                    <li><div class="row">fade div 1</div></li>          
                    <li><div class="row">fade div 2</div></li>
                    <li><div class="row">fade div 3</div></li>      
                </ul>
            </div>
        </div>
    </li>


    <li>
        <div class="row">   
            <h1>This is slide 2</h1>
        </div>
    </li>

</ul>           
</div> 

I have solved it by using this example here:

Flexslider.js update
slider.container = $(slider.containerSelector, slider).first(); //added .first()
selector: ".slides:first > li", //added :first

Maybe this can help someone else :-)


回答1:


I just change the default selector from ".slides > li" to ".slides:first > li"like this:

$(selector).flexslider({
  selector: '.slides:first > li',
  ...
});

It works like a charm, we don't even need to change the core js file. Thanks for the issue dicussion.



来源:https://stackoverflow.com/questions/14770351/woothemes-flexslider-one-unique-flexslider-inside-another-flexslider-is-it-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!