私はcycle2を使用しており、プログラムで別のscripts.jsファイルに設定しています。プログレッシブローディングを追加する前までは、スライダーはすべてうまく機能しています。ページに複数のスライダーがあるため、次のように設定しました。
$('.slider').each(function () {
var $this = $(this);
$this.cycle({
fx: 'scrollHorz',
slides: '> a',
sync: true,
progressive: slides,
speed: 'fast',
timeout: 0,
autoHeight: 'container',
next: $this.next('.slider-navigation').find('.next'),
prev: $this.next('.slider-navigation').find('.prev'),
loader: true
});
});
そして、例として、各スライダーの HTML マークアップは次のとおりです。
<div class="slider">
<a href="/">
<img src="example.jpg">
</a>
<script class="other-slides" type="text/cycle">
var slides = [
"<a href=" / "><img src="
another - example.jpg " /></a>",
"<a href=" / "><img src="
another - example.jpg " /></a>",
"<a href=" / "><img src="
another - example.jpg " /></a>"
];
</script>
</div>
ただし、ページをロードすると、コンソールに次のように表示されます: init が script.js にあり、このマークアップが別のページにあるため、これはReferenceError: slides is not defined
理にかなっていますが、どうすればこれを機能させることができますか、またはより良い方法がありますか? cycle
ページには複数のスライダーがあることに注意してください。
ありがとう、R