[英]Owl carousel not displayed
I'm trying to use OwlCarousel version 2.0 together with Bootstrap 3 and Meteor. 我正在尝试将OwlCarousel 2.0版与Bootstrap 3和Meteor结合使用。
I create a template for the carousel like this: 我为轮播创建模板,如下所示:
<template name="featuredCarousel">
<div class = "row">
<div class="owl-carousel">
<div class="item"><h4>1</h4></div>
<div class="item"><h4>2</h4></div>
<div class="item"><h4>3</h4></div>
</div>
</div>
</template>
I include this in my index.html file: 我将其包含在index.html文件中:
<div class="container">
{{> featuredCarousel}}
</div>
Finally, I have a separate .js-file for instantiating the carousel: 最后,我有一个单独的.js文件用于实例化轮播:
$('.owl-carousel').owlCarousel({
loop:true
});
This code is largely copied from the documentation. 此代码大部分是从文档中复制的。 Therefore, I would expect it to work. 因此,我希望它能起作用。 However, it simply displays nothing. 但是,它什么也不显示。 The carousel seems to be the problem here, because when I remove the .owl-carousel class from the div, the elements are displayed (though not in a carousel of course). 轮播似乎是这里的问题,因为当我从div中删除.owl-carousel类时,将显示元素(尽管当然不在轮播中)。
Can anyone tell me why this is not working and how to get it working? 谁能告诉我为什么这不起作用以及如何使其起作用? I would really appreciate your help. 我将衷心感谢您的帮助。
Thanks, 谢谢,
Tony 托尼
You need to put the instantiation code inside a rendered callback: 您需要将实例化代码放入渲染的回调中:
Template.featuredCarousel.rendered = function() {
$('.owl-carousel').owlCarousel({
loop:true
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.