开发者

Jquery Cycle: Can't navigate through slides

I'm trying to make a slider with jQuery Cycle where, when you click on one of 5 thumbnails, you switch to the right slide in the slider. Those thumbs are external to the slider.

Thing is, for some reason, the startingSlide argument doesn't work and just doing .cycle(number) doesn't either, even if the slider is clearly running. Here's a peek at the code:

JS

        jQuery(document).ready(function(){
        var current_slide;
        jQuery('#slider_accueil').cycle({ 
            fx:     'fade',
            timeout: 3000,
            after: onAfter,
            startingSlide: 0,
            pager: '#nav',
            next: '.next_btn_slider',
            prev: '.prev_btn_slider'
        });

        function onAfter(curr,next,opts){
            jQuery('.indicator').removeClass('current')
            current_slide=opts.currSlide + 1
            jQuery('#thumb'+current_slide+' .indicator').addClass('current')
        }

        jQuery('#thumb1').click(function(){
            jQuery('#slider_accueil').cycle(0);
            return false;
        })

        jQuery('#thumb2').click(function(){
            jQuery('#slider_accueil').cycle(1); 
            return false;
        })

        jQuery('#thumb3').click(function(){
            jQuery('#slider_accueil').cycle(2); 
            return false;
        })

        jQuery('#thumb4').click(function(){
            jQuery('#slider_accueil').cycle(3); 
            return false;
        })

        jQuery('#thumb5').click(function(){
            jQuery('#slider_accueil').cycle(4); 
            return false;
        })
    })

html

<div id="sliderAccueil">
            <div id="nav" style="display:none;"></div>
            <img src="/wp-content/themes/customtheme/images/slider_previous.png" class="prev_btn_slider">
            <img src="/wp-content/themes/customtheme/images/slider_next.png" class="next_btn_slider">
            <div id="slider_accueil" style="position: relative;">
                                    <div style="position: absolute; top: 0px; left: 0px; z-index: 5; opacity: 0; display: none;">
                    <img src="/wp-content/uploads/2011/09/slider1.jpg">
                    <div>
                        <div class="maintext">
                            <h2>Slide 1</h2>
                            <p>Slide 1</p>
                        </div>
                        <div class="link">
                            <b href="/"></a>
                            <b class="call_slide" href="/"><ig src="/wp-content/themes/customtheme/images/call_slider.png"></a>
                        </div>
                    </div>
                </div>
                                    <div style="position: absolute; top: 0px; left: 0px; z-index: 4; display: none; opacity: 0;">
                    <ig src="/wp-content/uploads/2011/09/slider2.jpg">
                    <div>
                        <div class="maintext">
                            <h2>Slide 2</h2>
                            <p>Slide 2</p>
                        </div>
                        <div class="link">
                            <b href="/"></a>
                            <b class="call_slide" href="/"><img src="/wp-content/themes/customtheme/images/call_slider.png"></a>
                        </div>
                    </div>
                </div>
                                    <div style="position: absolute; top: 0px; left: 0px; z-index: 3; display: block; opacity: 0.942616;">
                    <img src="/wp-content/uploads/2011/09/slider3.jpg">
                    <div>
                        <div class="maintext">
                            <h2>Reprise des travaux majeurs</h2>
                            <p>Slide 3</p>
                        </div>
                        <div class="link">
                            <b href="/"></a>
                            <b class="call_slide" href="/"><img src="/wp-content/themes/customtheme/images/call_slider.png"></a>
                        </div>
                    </div>
                </div>
                                    <div style="position: absolute; top: 0px; left: 0px; z-index: 2; display: block; opacity: 0.0573843;">
                    <img src="/wp-content/uploads/2011/09/slider4.jpg">
                    <div>
                        <div class="maintext">
                            <h2>Slide 4</h2>
                            <p>Slide 4</p>
                        </div>
                        <div class="link">
       开发者_开发技巧                     <b href="/"></a>
                            <b class="call_slide" href="/"><img src="/wp-content/themes/customtheme/images/call_slider.png"></a>
                        </div>
                    </div>
                </div>
                                    <div style="position: absolute; top: 0px; left: 0px; z-index: 1; display: none; opacity: 0;">
                    <img src="/wp-content/uploads/2011/09/slider5.jpg">
                    <div>
                        <div class="maintext">
                            <h2>Slide 5</h2>
                            <p>Slide 5</p>
                        </div>
                        <div class="link">
                            <b href="/"></a>
                            <b class="call_slide" href="/"><img src="/wp-content/themes/customtheme/images/call_slider.png"></a>
                        </div>
                    </div>
                </div>
                                </div>
            <div id="thumbnails_slider_accueil">
                <ul>
                                                                    <li>
                        <b id="thumb1" href="#1">
                            <div class="indicator"></div>
                            <div style="background-image:url(/wp-content/uploads/2011/09/thumb1.png)" class="thumbnail">
                                <p>Voies retranchées trains ajoutés</p>
                            </div>
                            <div class="clear"></div>
                                                        </a>
                    </li>
                                            <li>
                        <b id="thumb2" href="#2">
                            <div class="indicator"></div>
                            <div style="background-image:url(/wp-content/uploads/2011/09/thumb2.jpg)" class="thumbnail">
                                <p>Événements</p>
                            </div>
                            <div class="clear"></div>
                                                        </a>
                    </li>
                                            <li>
                        <b id="thumb3" href="#3">
                            <div class="indicator current"></div>
                            <div style="background-image:url(/wp-content/uploads/2011/09/thumb3.jpg)" class="thumbnail">
                                <p></p>
                            </div>
                            <div class="clear"></div>
                                                        </a>
                    </li>
                                            <li>
                        <b id="thumb4" href="#4">
                            <div class="indicator"></div>
                            <div style="background-image:url(/wp-content/uploads/2011/09/thumb4.jpg)" class="thumbnail">
                                <p>Appels d'offres</p>
                            </div>
                            <div class="clear"></div>
                                                        </a>
                    </li>
                                            <li>
                        <b id="thumb5" href="#5">
                            <div class="indicator"></div>
                            <div style="background-image:url(/wp-content/uploads/2011/09/thumb5.jpg)" class="thumbnail">
                                <p>Environnement</p>
                            </div>
                            <div class="clear"></div>
                                                        </a>
                    </li>
                                        </ul>
            </div>
            <div class="clear"></div>
        </div>

^check source, seems I cant put that cleaner than this.

Anybody have an idea?

PS, It's on purpose that all img are ig and all links are ... Stackoverflow wouldn't let me post.


I found the answer to my own question...

Seems that to use jQuery('#slider_accueil').cycle(0); you need to have the full version linked, and not the lite.

Seems like that function is one of those who have been taken out from the conversion from full to lite... Note to self: The lite versions may not have the function you want to do... just spent 2 hours trying all kinds of stuff on that. :p

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜