我使用的是http://jquery.malsup.com/cycle2/api/,我試圖在檢測到移動設備時摧毀窗口大小調整事件的cycle2滑塊。不幸的是它返回以下兩個錯誤:摧毀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');
}
});
});
謝謝。