Callback events not working - using Owl Carousel

13,189

Solution 1

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

Solution 2

You need to upgrade to the new version.

https://github.com/OwlCarousel2/OwlCarousel2/archive/2.2.1.zip

Share:
13,189
TylersSN
Author by

TylersSN

Updated on August 06, 2022

Comments

  • TylersSN
    TylersSN almost 2 years

    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>
    
  • A J
    A J over 8 years
    Please identify the changes and notify the user who has asked the question about it