0

单击动态生成的标签时,我需要加载 jquery 花式框。当我第一次单击链接时,不会出现花哨的框,当它在第二次单击时加载。

你能给我一个解决方案吗?这是我的代码,

$(document).ready(function()
    {   
        $(".app a").live('click',function(e){

        e.preventDefault();
        var contentId = $(this).attr('id');

            $("#"+contentId).fancybox({            
                'titleShow'     : false,
                'padding'       : 0,
                'transitionIn'  : 'elastic',
                'transitionOut' : 'elastic',
                'autoDimensions':false, 
                'width'     :380, 
                'height'        :500,
                'showCloseButton' : true,
                'hideOnOverlayClick' : false            
            });

        });
    });


<div class="app"> 
  <a href="#device_detection" id="apps_<?= $regUsers->id; ?>"> click here</a>
</div>
4

1 回答 1

2

按照这篇文章
在第一次单击时,您只是在初始化fancybox,您需要通过执行此操作来触发fancybox 的事件侦听器

$("#"+contentId).fancybox({            
    'titleShow'     : false,
    ...
}).trigger("click");
于 2012-10-02T13:24:51.647 回答