[英]How can I define callback function for an option in Owl Carousel 2?
I am trying to change value of an option by coming value from database. 我试图通过从数据库中获取价值来改变期权的价值。 In order to do this, I think i should define a callback function.
为了做到这一点,我认为我应该定义一个回调函数。 But it's not working.
但这不起作用。
My callback function is: 我的回调函数是:
function nav_cb(){
if( settings.nav==='on' ){
return true;
}else{
return false;
}
}
And my init codes are here. 我的初始化代码在这里。
var owl = $('.owl-carousel');
owl.owlCarousel({
loop: true,
nav: nav_cb,
dots: true,
});
But it doesn't accept this result of function. 但是它不接受函数的这种结果。 How can i make it return true or false?
如何使它返回true或false?
I've just found it myself. 我自己找到了。 They should be like this.
他们应该是这样的。 Working fine.
工作正常。
var nav_check = 0;
if( settings.nav==='on' ){
nav_check = true;
}else{
nav_check = false;
}
var owl = $('.owl-carousel');
owl.owlCarousel({
loop: true,
nav: nav_check,
dots: true,
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.