Facebox plugin does not delete previous content when used with Live

I use facebox in the content that I downloaded ajax

Usually, the plugin deletes the previous content, therefore, several times clicking on the same link will still show one image.

But not used with live. He will add images

Setting this empty below will not work? Does he already do this in the plugin?

$('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 length of the div actually says 0, but still shows the full stack)

How can I do this work live?

thanks Richard

+3
source share
1 answer

Try emptying the contents of the box by binding it to beforeReveal:

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

Source: https://habr.com/ru/post/1731751/


All Articles