我正在使用http://jquery.malsup.com/cycle2/api/并且当我检测到移动设备时,我试图在窗口调整大小事件中销毁 cycle2 滑块。不幸的是,它返回以下两个错误:
[cycle2] slideshow must be initialized before sending commands; "destroy" ignored
[cycle2] slideshow must be initialized before sending commands; "reinit" ignored
也许有人可以帮忙,我做错了什么?这是代码:
$(function() {
var slider = $('.slider').cycle();
condition = true;
//destroy onload under condition
if(condition){
slider.cycle('destroy');
}
//destroy on resize
$(window).on('resize',function() {
condition = true; //Will be function to recondition let´s say it's true by now
if(condition){
slider.cycle('destroy');
} else {
slider.cycle('reinit');
}
});
});
谢谢你。