views:

131

answers:

1

Hi,

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

Normally, 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

+2  A: 

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

$(document).bind('beforeReveal.facebox', function() {
    $("#facebox .content").empty();
});
karim79
thanks a lot, I don't know anything about hooks. I saw the comments in the file, but it diddn't ring a bell.If I put this in the mousedown event it wil cause a slight flickr, but outside works fine. Oh, and it should be $("#facebox .content").
Richard