A
A
advancess2020-07-15 17:20:55
Owl Carousel
advancess, 2020-07-15 17:20:55

Owl reinitialization. How to make owl carousel friends with ajax?

Can't re-call owl carousel after ajax content is loaded.
Tried like this but doesn't work:

$(".news__item__gallery").data('owlCarousel').destroy();


I call AJAX content like this

$('.popup-with-form').magnificPopup({
    type: 'ajax',
  mainClass: "mfp-fade",
    closeBtnInside: true,
    gallery: {
      enabled: true,
    },
    callbacks: {
        ajaxContentAdded: function() {
      			
          $(".news__item__gallery").data('owlCarousel').destroy();
   
    
        }
    }
});


Owl like this:
$('.news__item__gallery').owlCarousel({
         loop: true,
         margin: 50,
         dots: false,
         nav: true,
         responsive: {
         	0: {
         		items: 1
         	},
         	720: {
         		items: 3
         	},
         	1000: {
         		items: 4
         	}
         }
         })

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question