Owl Carousel data options for multiple sliders on page -


i found code here: https://stackoverflow.com/a/32636784/2785140 unfortunately not work correctly if page contains more 1 slider.

var oc = $('.owl-carousel');   var ocoptions = oc.data('carousel-options');   var defaults = {     loop:            true,     nav:             false,     autoplay:        true,   }   oc.owlcarousel( $.extend( defaults, ocoptions) ); 

html:

<div class="owl-carousel" data-carousel-options='{"autoplay":"true","autoplaytimeout":"6000","items":"2"}'> ... </div> 

how make work on multiple sliders?

thanks in advance.

init each carousel:

var oc = $('.owl-carousel'); oc.each(function () {     var el = $(this);     el.owlcarousel($.extend({         autoplay: 2000,         loop: true,         items: 4,         autowidth: true,         nav: false,         dots: false,         margin: 30     }, el.data('carousel-options'))); }); 

Comments