resetting bxSlider

前端 未结 9 1565
滥情空心
滥情空心 2021-01-06 06:45

I took a different direction with a carousel I implemented, opting for bxSlider instead of jCarousel. This is for an image gallery I am building http://rjwcollective.com/equ

相关标签:
9条回答
  • 2021-01-06 07:42

    I was writing a program which make a bunch of AJAX calls on a timer and displays the results in a bxslider and I also ran into a problem where the bxslider wasn't refreshing.This is how I solved it:

    var $slider = null;
    

    And inside the portion of code where you need to initialize or refresh the slider do this:

    if ($slider == null) {
        $slider = $('.sliderDashboard').bxSlider({
            slideWidth: 200,
            minSlides: 1,
            maxSlides: 1,
            slideMargin: 10
        });
    }
    else {
        $slider.reloadSlider();
    }
    
    0 讨论(0)
  • 2021-01-06 07:47

    As the website says: you have the slideshowContainer to be attached to a variable in order to use the public functions. As reloadShow() and destroyShow() are public functions, this is the only way to go. Worked perfectly for me. I've simply put a

    var $theslideshow = [functionThatCallsYourSlideshow] 
    

    before my function and called afterwards $theslideshow.destroyShow();

    hope this helps

    0 讨论(0)
  • 2021-01-06 07:48

    Declaring the "mySlider" variable outside the document-ready block solved the problem for me:

    var mySlider;
    $(function(){
        mySlider= $('#slider').bxSlider({
            auto: true,
            controls: true
        });
    
        mySlider.reloadShow();
    })
    

    Alex

    0 讨论(0)
提交回复
热议问题