http://jquery.malsup.com/cycle2/api/を使用しています。モバイル デバイスを検出すると、ウィンドウのサイズ変更イベントで cycle2 スライダーを破棄しようとしています。残念ながら、次の 2 つのエラーが返されます。
[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');
}
});
});
ありがとうございました。