Detect when slick slider initialises

守給你的承諾、 提交于 2019-12-22 03:25:09

问题


I'm trying to fire some code when slick initializes. Apparently in the newest version 1.4 "callback methods have been deprecated and replaced with events."

This doesn't work for me though:

$('.spv-slider').on('init', function(event, slick){
    console.log("initialised")
});

what's wrong with it?


回答1:


I'm not sure at which point you tried to initialize slickslider, but you have to do it after binding the init event.

So write your piece of code as you did and after that initialize the slider:

$('.spv-slider').on('init', function(event, slick){
    console.log("initialized")
});

And then:

$('.spv-slider').slick();


来源:https://stackoverflow.com/questions/28236840/detect-when-slick-slider-initialises

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!