Reinitialize Slick js after successful ajax call

前端 未结 11 1630
傲寒
傲寒 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:25

    I had to unslick the carousel before the ajax call starts, but you can't do that until there is already a slick carousel. So, I set a variable to 0 and only run unslick after it changed

    var slide = 0
    if(slide>0)      
    $('#ui-id-1').slick('unslick');
    
            $.ajax({
                //do stuff, here
            },
            success: function( data ) {
    
                $('#ui-id-1').slick();
                slide++;
    
            }
    

提交回复
热议问题