Callback events not working - using Owl Carousel

TylersSN picture TylersSN · Feb 6, 2015 · Viewed 12.3k times · Source

I am trying to detect when Owl Carousel is ready to be manipulated so that I can add content to it. The script below initiates the carousel but the initialized event never triggers.

<script type="text/javascript">
    jQuery(document).ready(function () {
        var owl = jQuery("#owl-example");
        owl.on('initialized.owl.carousel', function(e) { 
              alert('hi');
        }).owlCarousel({  
            navigation: true,
            goToFirstSpeed: 2000,
            singleItem: false,
            transitionStyle: "fade",
            items:<?=$_productCollection->getPageSize()?>,
            lazyLoad: true,
            autoWidth:true, 
            scrollPerPage:true,
            mouseDrag:false,
            touchDrag: false,  
            startPosition: "zero",
            navigationText: [
                "<strong>&lt;</strong>", //this equates to "<"
                "<strong>&gt;</strong>" //this equates to ">"
            ] 
        });
        ;
    });

</script>

Answer

Husamuddin picture Husamuddin · Aug 6, 2015

initialize.owl.carousel and initialized.owl.carousel events must be attached before Owl Carousel initialization

Check this link of the documentation https://owlcarousel2.github.io/OwlCarousel2/docs/api-events.html