0

I need to stop the bx-slider autoslideshow when the next button gets clicked, I have the following code.

$(document).ready(function(){
    elementSlider=$(".monitor_slider").bxSlider({
    auto: true, pager: false,
});
$(".monitor_slider_container .bx-wrapper .bx-next").click(function(e){
        if(e.originalEvent !== undefined){
            elementSlider.stopAuto();
        }
    });
});

No erros, but the slider keeps on changin automatically.

Any help will be really appreciated.

And forgive my bad english.

carcargi
  • 516
  • 2
  • 8
  • 23

2 Answers2

1

UPDATE

Now you can just add the parameter stopAutoOnClick: true and it will stop on click of the controls Next/Prev

$('.bxslider').bxSlider({
  auto: true,
  autoControls: true,
  stopAutoOnClick: true
});

Source : https://bxslider.com/examples/auto-show-start-stop-controls/

Warface
  • 5,029
  • 9
  • 56
  • 82
0

Thanks to @Rikard, I needed to write my own controls. The code now looks like this and the problem is solved.

$(document).ready(function(){
    elementSlider=$(".monitor_slider").bxSlider({
    auto: true, pager: false,
});

    $(".bx-next").toggleClass("px-next");
    $(".px-next").toggleClass("bx-next");
$(".px-next").click(function(e){
        if(e.originalEvent !== undefined){
            elementSlider.goToNextSlide();
            return false;    
        }
    });

    $(".bx-prev").toggleClass("px-prev");
    $(".px-prev").toggleClass("bx-prev");
    $(".px-prev").click(function(e){
        if(e.originalEvent !== undefined){
            elementSlider.goToPreviousSlide();
            return false;    
        }
    });
});

It seems that when you use the goToNextSlide and goToPreviousSlide functions the autoshow stops.

carcargi
  • 516
  • 2
  • 8
  • 23