jQuery Cycle插件(零元素?) [英] jQuery Cycle Plugin (zero element?)

查看:115
本文介绍了jQuery Cycle插件(零元素?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆