灯箱未获取应用的图像

时间:2012-10-25 19:24:42

标签: jquery image lightbox lightbox2

我有一些关于LightBox for images的问题

问题是当我从外部php文件加载图像时,它没有在灯箱中显示图像。

    <script type="text/javascript">
    $(document).ready(function(){   
    //Display Loading Image
    function Display_Load()
    {
        $("#loading").fadeIn(900,0);
        $("#loading").html("<img src='../images/lightbox-ico-loading.gif' />");
    }
    //Hide Loading Image
    function Hide_Load()
    {
        $("#loading").fadeOut('slow');
    };

   //Default Starting Page Results

    Display_Load();

    $("#content").load("images.php?page=1&uid=28", Hide_Load(), lightBox());

    //Pagination Click
    $("#pagination li").click(function(){

        Display_Load();

        //Loading Data
        var pageNum = this.id;
        var uid = 1;
        uid = "<?php echo $id; ?>";
        $("#content").load("images.php?page=" + pageNum + "&uid=" + uid, Hide_Load());
    });


});
    </script>

它会加载下面框中的所有图像,但没有任何灯箱效果。

<center><div id="loading" ></div>
                            <div id="content"></div>
            </center>

通常在灯箱中显示图像我们将执行类似下面的操作,并且它在所有其他地方工作正常,然后只有上面的代码有问题。

    <script type="text/javascript">
$(function() {
    $('#gallery a').lightBox();
});
</script>

任何人都可以分享一些有关它的提示。

谢谢你提前。

1 个答案:

答案 0 :(得分:1)

试试这个:http://docs.jquery.com/Plugins/livequery

使用此插件,您可以执行以下操作:

$('#gallery a').livequery(function() { $(this).lightBox() });

这样,.lightBox()将应用于初始页面加载后添加的选择器。