jQuery Cycle插件(零元素?) [英] jQuery Cycle Plugin (zero element?)
问题描述
我使用AJAX填充div,然后将其插入循环!
I used AJAX to populate a div and then, cycle plugin it !
这是页面,这是代码调用周期:
here is the page, and here is the code calling cycle:
<script type="text/javascript">
$(function() {
$("#photoviewer").load("photo-list.shtml #ani");
alert ('photo loaded!');
$(document).ready(function() {
$('#ani').cycle({ fx: 'turnDown',
speed: 'fast',
timeout: 0,
pager: '#nav' });
alert('done!');
});
});
</script>
我收到此错误:[周期]终止;选择器找到了零个元素,但是有了萤火虫,我看到的图像列表应该在该位置...
I get this error : [cycle] terminating; zero elements found by selector, but with firebug i SEE the image list as where it should be...
所以我一无所知,欢迎您的帮助!
so i am clueless, any help welcome !
***请注意,错误控制台(警告部分)快要疯了!
*** take note, the error console (warning section) is going crazy !
推荐答案
而不是在$(document).ready()
中初始化循环,而是在load
回调中执行此操作,以使其在您的ajax调用完成并构建后才执行. #ani div
:
Instead of initializing cycle in $(document).ready()
, do it in a load
callback so that it doesn't execute until your ajax call has completed and built the #ani div
:
$(function() {
$("#photoviewer").load("photo-list.shtml #ani", function() {
$('#ani').cycle({ fx: 'turnDown',
speed: 'fast',
timeout: 0,
pager: '#nav' });
});
});
按现状,循环插件初始化是在加载图像之前(在load
函数完成之前)执行的.
As it stands, the cycle plugin initialization is executing before the images have loaded (before the load
function has finished).
这篇关于jQuery Cycle插件(零元素?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!