Stiller Eugen
Stiller Eugen

Reputation: 701

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

Upvotes: 7

Views: 10636

Answers (1)

Matt Mintun
Matt Mintun

Reputation: 626

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
});

Upvotes: 39

Related Questions