【发布时间】:2014-08-21 01:02:18
【问题描述】:
我正在使用 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>
但是,现在当我加载页面时,我的控制台状态:ReferenceError: slides is not defined 这很有意义,因为cycle init 在 script.js 中,并且这个标记在另一个页面上,但是我怎样才能使它工作,或者,还有更好的方法?请记住,页面上有多个滑块。
谢谢, 回复
【问题讨论】:
标签: javascript jquery jquery-cycle jquery-cycle2