Reinitialize Slick js after successful ajax call

前端 未结 11 1615
傲寒
傲寒 2021-02-01 16:52

I am using Slick for a carousel implementation and everything works fine when the pages loads.What I am trying to achieve is that when i make an Ajax call to retrieve new data I

11条回答
  •  清歌不尽
    2021-02-01 17:13

    Note: I am not sure if this is correct but you can give it a try and see if this works.

    There is a unslick method which de-initializes the carousel, so you might try using that before re-initializing it.

    $.ajax({
        type: 'get',
        url: '/public/index',
        dataType: 'script',
        data: data_send,
        success: function() {
            $('.skills_section').unslick();  // destroy the previous instance
            slickCarousel();
          }
    });
    

    Hope this helps.

提交回复
热议问题