slick slider init doesn't fire
Asked Answered
T

1

7

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

Tedesco answered 28/11, 2016 at 16:13 Comment(2)
Does the reInit event work? If so, try declaring your 'init' event after declaring $el.slick().Suburb
Here's a working fiddle jsfiddle.net/1yvr86yp/32Suburb
O
38

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
});
Oskar answered 17/1, 2020 at 22:31 Comment(5)
Saved my time. Worked ! Thank you!Curley
"X years later, hoping it helps people" is the content I am here for! Thanks Matt, thanks stackoverflow!Birchard
Still helping in 2021! Thank you!Titlark
@Matt Mintun In this realization slick argument is just an event of init, but not a real slick slider.Allgood
Huge help, and just in time! Thank you!Blackfoot

© 2022 - 2024 — McMap. All rights reserved.