6

我正在尝试检测 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>
4

2 回答 2

9

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

检查文档的此链接https://owlcarousel2.github.io/OwlCarousel2/docs/api-events.html

于 2015-08-06T02:41:59.247 回答
1

您需要升级到新版本。

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

于 2015-12-02T16:48:24.353 回答