开发者

Facebox plugin is not removing previous content when used with live

I am using facebox in the content that I have loaded with ajax

No开发者_如何学Crmally, the plugin removes previous content, so clicking multiple times on the same link would still show the one image.

But not used with live. It will stack up the images

Setting it to empty below will not work??It already does that in the plugin also?

$('a[rel*=facebox]').live("mousedown", function() { 

if( $('#facebox .content div').length > 0 ) $('#facebox .content div').empty(); 
a = $('#facebox .content div').length;
$('#counter').html(a);

    $(this).facebox(); 

});

(The div length actually says 0 , but still shows the full stack)

How could I make this work with live?

thanks, Richard


Try emptying the contents of the facebox by binding to its beforeReveal hook:

$(document).bind('beforeReveal.facebox', function() {
    $("#facebox .content").empty();
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜