question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

1.4.x callback methods - on init event not working

See original GitHub issue

New callback events

Is anyone else having an issue with the init event? I’m having trouble getting init to work at all.

With the following code the beforeChange and afterChange events work, but the init event doesn’t fire at all. I have tried version 1.4.0 and 1.4.1

My code looks like this:

    $('.slider')
        .on('init', function(event, slick){
            // let's do this after we init the banner slider
            ...
            console.log('slider was initialized');
        })
        .on('beforeChange', function(event, slick, currentSlide, nextSlide){
            // then let's do this before changing slides
            ...
            console.log('before change');
        })
        .on('afterChange', function(event, slick, currentSlide, nextSlide){
            // finally let's do this after changing slides
            ...
            console.log('after change');
        });

Using 1.3.9 and the older callback method the onInit works

    $('.slider').slick({
        autoplay: true,
        autoplaySpeed: 5000,
        slidesToShow: 1,
        slidesToScroll: 1,
        dots: true,
        lazyLoad: 'ondemand',
        onInit: function() {
            // let's do this after we init the banner slider
            ...
            console.log('slider was initialized');
        },
        onBeforeChange: function() {
            // then let's do this before changing slides
            ...
            console.log('before change');
        },
        onAfterChange: function() {
            // finally let's do this after changing slides
            ...
            console.log('after change');
        }
    });

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:22 (3 by maintainers)

github_iconTop GitHub Comments

62reactions
kenwheelercommented, Feb 7, 2015

You need to bind it before calling slick on the element

43reactions
daslichtcommented, Aug 3, 2016

is there an event after slick is ready ?

in the init callback slick is not available yet 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

JQuery UI event callbacks not triggering when set in initializer
I have stumbled upon this type of problem myself. It seems that the bind events and the initializer events are not the same...
Read more >
ORM Events - SQLAlchemy 1.4 Documentation
Note that this event only fires when the actual rollback against the database occurs - it does not fire each time the Session.rollback()...
Read more >
bokeh.events — Bokeh 2.4.0 Documentation
The classes in this module represent these different events, so that callbacks can be attached and executed when they occur. It is possible...
Read more >
pygame.event — pygame v2.1.4 documentation
Usually, this should be called once per game loop. Note: Joysticks will not send any events until the device has been initialized. The...
Read more >
SugarCube v2 Documentation - Motoslave.net
For example, the following will not work because the macro parser will ... callback : (function) The function used to produce members of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found