Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

slick slider init doesn't fire

Im using Slick Slider (http://kenwheeler.github.io/slick/) for my slider and try to put the current slide into the caption.

Code:

var $el = $('.mgu-basic-slider');

$el.on('init'), function() {
    console.log('dd');
}
$el.slick({
     dots:false,
    adaptiveHeight: true,
    arrows : true
})

$el.on('reInit afterChange', function(event, slick, currentSlide, nextSlide){
var i = (currentSlide ? currentSlide : 0) + 1;
$( ".slick-counter" ).text(i + '/' + slick.slideCount);
});

It seems, that the inti-function doesn't work, any idea why? Thanks for help

like image 358
Stiller Eugen Avatar asked Nov 29 '22 13:11

Stiller Eugen


1 Answers

4 years later... but hopefully helps someone... you need to bind init prior to your slider and format your jQuery properly. Not sure about reInit.

var $el = $('.mgu-basic-slider');

$el.on('init', function(slick) { // <-- Your code here was malformed
    console.log('Init');
});

$el.slick({
    dots:false,
    adaptiveHeight: true,
    arrows : true
});
like image 83
Matt Mintun Avatar answered Dec 11 '22 00:12

Matt Mintun