Can't get slickGoTo working for custom slick navigation
Asked Answered
T

1

6

Trying to use slick carousel and use my own custom icons for navigation instead of the default thoughts. I thought the best way to do this would be to set up my own list and use slickGoTo, but I can't get it to work.

$(document).ready(function(){

    $('.rps-slider').slick({
      infinite: true,
      arrows: true,
      dots:true
    });

    $(".slick-nav li a").click(function(e){
      var slideIndex = $(this).index();
      $( ".rps-slider" ).slickGoTo(parseInt(slideIndex));
    });

  });

jsfiddle here: http://jsfiddle.net/r7vjy7as/

Tancred answered 6/2, 2015 at 15:11 Comment(0)
C
16

Use $( ".rps-slider" ).slick('slickGoTo', parseInt(slideIndex));

Cuttlebone answered 11/2, 2015 at 14:20 Comment(1)
Also, set slideindex to track the index of its parent 'li', because the index of 'li a' will always be 0, 'a' being the only element inside the 'li'. var slideIndex = $(this).parent().index();Forcemeat

© 2022 - 2024 — McMap. All rights reserved.