回调事件无效 - 使用Owl Carousel

Tyl*_*sSN 4 javascript jquery owl-carousel-2

我试图检测Owl Carousel何时可以被操作,以便我可以添加内容.下面的脚本启动轮播,但初始化事件永远不会触发.

<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>
Run Code Online (Sandbox Code Playgroud)

Hus*_*din 7

在Owl Carousel初始化之前必须附加initialize.owl.carouselinitialized.owl.carousel事件

查看文档的这个链接https://owlcarousel2.github.io/OwlCarousel2/docs/api-events.html