jQuery Cycle - img 幻灯片未加载,重新排队幻灯片放映
我正在使用 jQuery Cycle 插件创建一个非常简单的幻灯片:
标记:
<div class="gallery group">
<div class="slide-nav">
<a href="#" class="previous">« Ver anterior</a>
<a href="#" class="view">Ver Ficha</a>
<a href="#" class="next">Ver siguiente »</a>
</div><!-- /slide-nav -->
<div class="slider">
<div class="slides">
<img src="img/gallery01.jpg" alt="" />
<img src="img/gallery02.jpg" alt="" />
<img src="img/gallery01.jpg" alt="" />
<img src="img/gallery02.jpg" alt="" />
</div>
<div class="thumbs"></div>
</div><!-- /slider -->
</div><!-- /gallery -->
脚本:
jQuery('.gallery .slider .slides').cycle({
fx: 'fade',
speed: '800',
timeout: 3000,
prev: '.gallery .slide-nav a.previous',
next: '.gallery .slide-nav a.next',
pager: '.gallery .slider .thumbs',
// callback fn that creates a thumbnail to use as pager anchor
pagerAnchorBuilder: function(idx, slide) {
var img = jQuery(slide).find("img").attr("src");
return '<a href="#"><img src="' + img + '" /></a>';
}
});
pagerAnchorBuilder
是在 pager
中创建缩略图的函数 (.thumbs 在我的例子中)。这个想法是,缩略图是在
.thumbs
中创建的,而 .slides
是幻灯片的包装器(在我的例子中是图像)。
但是,我在控制台中登录(不是错误或警告,只是日志):
[cycle] 1 - img 幻灯片未加载, 重新排队幻灯片: gallery01.jpg 0 0
幻灯片放映仍然有效,但它不会创建缩略图,告诉我 pagerAnchorBuilder
函数中的 img
变量未定义。
知道“重新排队幻灯片放映”是什么意思以及为什么图像未定义吗?我过去多次使用过这个确切的片段,但以前从未遇到过这个问题。
I'm using jQuery Cycle plugin to create a very simple slideshow:
Markup:
<div class="gallery group">
<div class="slide-nav">
<a href="#" class="previous">« Ver anterior</a>
<a href="#" class="view">Ver Ficha</a>
<a href="#" class="next">Ver siguiente »</a>
</div><!-- /slide-nav -->
<div class="slider">
<div class="slides">
<img src="img/gallery01.jpg" alt="" />
<img src="img/gallery02.jpg" alt="" />
<img src="img/gallery01.jpg" alt="" />
<img src="img/gallery02.jpg" alt="" />
</div>
<div class="thumbs"></div>
</div><!-- /slider -->
</div><!-- /gallery -->
Script:
jQuery('.gallery .slider .slides').cycle({
fx: 'fade',
speed: '800',
timeout: 3000,
prev: '.gallery .slide-nav a.previous',
next: '.gallery .slide-nav a.next',
pager: '.gallery .slider .thumbs',
// callback fn that creates a thumbnail to use as pager anchor
pagerAnchorBuilder: function(idx, slide) {
var img = jQuery(slide).find("img").attr("src");
return '<a href="#"><img src="' + img + '" /></a>';
}
});
pagerAnchorBuilder
is function that creates thumbnails in the pager
(.thumbs
in my example). The idea is that thumbnails are created in .thumbs
and .slides
is the wrapper for slides (images in my case).
However, I'm getting this in log in the console (not error or warning, just log):
[cycle] 1 - img slide not loaded,
requeuing slideshow: gallery01.jpg 0 0
The slideshow still works, but it doesn't create the thumbnails, telling me the img
variable from the pagerAnchorBuilder
function is undefined.
Any idea what the "requeuing slideshow" mean and why the image is undefined? I used this exact snippet many many times in the past, and never had this problem before.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯...
如果传入“pagerAnchorBuilder”回调的“幻灯片”将是“幻灯片”中的
元素之一
,那么你不需要“find()”。它应该只是:
或者更简单:
“.find()”方法永远不会包含起始元素;它只查看 DOM 中的后代。
Hmm ...
If the "slide" passed in to your "pagerAnchorBuilder" callback will be one of the
<img>
elements in the "slides"<div>
, then you don't need the "find()". It should be just:or, simpler:
The ".find()" method won't ever include the starting element; it only looks at descendants in the DOM.