开发者

Fancybox: Binding multiple DIVs that have the same class, but how can I access them individually in the onComplete function?

As you can see in the onComplete definition I am trying to access the HTML of the specific DIV that is currently being launched, but the bind call is done by class. If I have many DIVs all of the same class it is bound properly, this means that when I click the ".opener" anchor it pops up the proper content. However I can't figure out how to access that content from the onComplete function as it only ever gives back the first ".opener" every time, regardless of which one is being launched. Any ideas?

initFancyBox: function() {
    //ie hack for fancy box
    if ($(".dialog").length > 0 || $(".imageDetail").length > 0) {
        $(".opener").fancybox({
            'titlePosition': 'inside',
            'transitionIn': 'none',
            'transitionOut': 'none',
            'type': 'inline',
            'onComplete': func开发者_运维百科tion(){
                alert($(".opener").parent().html());                    
            }
        });
    } else {
        $(".opener").fancybox({
            'titlePosition': 'inside',
            'transitionIn': 'none',
            'transitionOut': 'none',
            'type': 'image'
        });

    }
}


If you want to do something for each of your items from the selector, try using something like:

$('.opener').each(function()
{

});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜