0

How can i change prev/next slick buttons action. I have a dynamically loadable carousel. So i need to add an image load action to buttons.

I tried to add action to slick declaration block like

    $(".mySlickCarousel").slick({
        prevArrow: function () {
           // code
        }
    })

tried this too:

$('.your-element .next-button').click(function(event){
  //load image
});

It doesn't work too. Well the browser get into the function only once. For a first time. Then ignoring

UPD: So, i solved it. As one guy told previously, you need to describe your own buttons

 prevArrow: $ ('.prev'),
 nextArrow: $ ('.next'),

and then do that

$(".next").on("click", function() {
    //your code
});

it's worked!

Ilya Khudyakov
  • 301
  • 3
  • 15

1 Answers1

0

Just load your load action to the next button of the carousel.

$('.your-element .next-button').click(function(event){
  //load image
});

Or use the slick callback event to have more input (currentSlide, nextSlide).

$('.your-element').on('beforeChange', function(event, slick, currentSlide, nextSlide){
  //load image
});
Thinh Nguyen
  • 392
  • 1
  • 8
  • Yes, first one is the easiest way. This is the first thing i tried to. It doesn't work. I don't know why, but it doesn't even get into this function. The second. well, probably it will work. But its a lot of things i have todo because i have to know the direction (next or previous). And by the way it will be called by swipe too.. anyways... there will be the plan B. – Ilya Khudyakov Mar 04 '16 at 07:43