Using Slick.js - how i can remove current active slide? I made of an example, but nothing works
var $status = $('.pagingInfo');
var $slickElement = $('.slideshow');
$slickElement.on('init reInit afterChange', function (event, slick, currentSlide, nextSlide) {
//currentSlide is undefined on init -- set it to 0 in this case (currentSlide is 0 based)
var i = (currentSlide ? currentSlide : 0) + 1;
$status.text(i + '/' + slick.slideCount);
});
$slickElement.slick({
slide: 'img',
speed: 1,
infinite: false,
swipe: false,
autoplay: false,
dots: false
});
$('.remove-slide').on('click', function() {
$slickElement.slick('slickRemove', i);
});
My fiddle here - http://jsfiddle.net/q5yae1t3/9/
You don't have an
i
variable set in the$(...).on(...)
function. You need to seti
in order to remove something based oni
. Then you also need to change all thedata-slick-index
attributes, because those weren't changed when the slide counter gets changed.http://jsfiddle.net/q5yae1t3/19/ Hope that helps!