Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refreshing Owl Carousel 2

I have 3 divs that activate slide toggle when I click on them. And inside every div there is owl carousel slider.

If I trigger one div the slider shows, but when I click other div slider doesn't show unless I resize the window.

How can I trigger refresh on slide toggle for the slider in every div?

I tried with this on slide toggle but it doesn't work:

$('.owl-slider').trigger('refresh.owl.carousel');
like image 601
vedran Avatar asked Sep 02 '15 08:09

vedran


People also ask

How do you reload an owl carousel?

You can initialize the carousel and store it in a variable and using that variable you can refresh the owl carousel. like the below example. var $owlCarousel = $('. owl-carousel').

Is owl carousel deprecated?

Owl Carousel hasn't been updated in 3 years and is officially deprecated by its maintainers.

How do you make owl carousel dynamically?

When you initialize the carousel store the carousel object in a variable for future use. var $owl = $("#owl-demo"). owlCarousel({ navigation: true, // Show next and prev buttons slideSpeed: 300, paginationSpeed: 400, items: 1, itemsDesktop: false, itemsDesktopSmall: false, itemsTablet: false, itemsMobile: false, });

How do you increase dots in an owl carousel?

owl. carousel', [$(this). index(), 300]); }); That should be all you need to get custom dots up and going with Owl Carousel 2.


2 Answers

You trigger with a class. You can try with a variable:

var $owl = $('.owl-carousel').owlCarousel({
    items: 1,
    loop:true
});

$owl.trigger('refresh.owl.carousel');
like image 57
egvrcn Avatar answered Sep 22 '22 13:09

egvrcn


if .trigger('refresh.owl.carousel'); didn't work with you, you can use

window.dispatchEvent(new Event('resize'));

which will make the carousel refresh automatically.

like image 36
Moaaid Jamal Avatar answered Sep 18 '22 13:09

Moaaid Jamal