Closed cheeseytoastie closed 4 years ago
Yes, you can use each()
to iterate though the carousel elements https://fizzy.school/un-repeat-with-functions
$('.carousel').each( function( i, carousel ) {
let $carousel = $( carousel );
$carousel.flickity({
autoPlay: $carousel.data('carousel-speed');
});
});
That looks perfect. Thanks!
Is is possible to do something like?
$carousel = $('.carousel').flickity({ autoPlay: $(this.element).data('carousel-speed'),
where I've put (by setting a value in a CMS) a data attribute on the markup.
There are multiple carousels on the page so though it this works (setting a single div with a value) it's not suitable, how can I get to the carousel element in the initialisation?!