How to reinitialize Owl Carousel after an ajax call?

后端 未结 7 1654
礼貌的吻别
礼貌的吻别 2020-12-20 12:12

I am trying to reinitialize Owl carousel after a successful ajax call. The ajax call will change the data but the view should stay the same.I am having an issue where the vi

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-20 12:32

    This should help:

    /*
     reinit() method reinitialize plugin 
    
     Syntax:
     owldata.reinit(newOptions)
    
     Yes! you can reinit plugin with new options. Old options
     will be overwritten if exist or added if new.
    
     You can easly add new content by ajax or change old options with reinit method.
     */
    
     $('.reinit').click(function(e){
     e.preventDefault()
     if(booleanValue === true){
      booleanValue = false;
      } else if(booleanValue === false){
      booleanValue = true;
    }
    
    owl.data('owlCarousel').reinit({
        singleItem : booleanValue
      });
    })
    

提交回复
热议问题