简体   繁体   中英

Call slick after click event

I got a problem calling a slick after click event.

$('.gallery').slick({
    dots: false,
    infinite: false,
    speed: 300,
    slidesToShow: 1,
    centerMode: false,
    variableWidth: true,
    arrows: true
});

This just works fine after page load, but the problem is with this code:

$('.slickit').on('click', function () {
    $('.gallery').slick({
        dots: false,
        infinite: false,
        speed: 300,
        slidesToShow: 1,
        centerMode: false,
        variableWidth: true,
        arrows: true
    });
});

I can't manage to call slick on click function.

The error is:

Uncaught TypeError: $(...).slick is not a function
at HTMLDivElement.<anonymous> (module.js:4)
at HTMLDivElement.dispatch (jquery-3.2.1.js:5206)
at HTMLDivElement.elemData.handle (jquery-3.2.1.js:5014)

问题可能是控制器未获取slick.js的库文件,只是在slick的初始化上方包含了slick.js的库文件,并确保更新了slick.js的版本。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM