Multiple Copies of Content in Facebox

590 views
Skip to first unread message

mjamesd

unread,
Jul 17, 2008, 4:46:08 PM7/17/08
to facebox
I have a page with menu items on the left side that use facebox and a
menu across the top that uses Prototype to make AJAX calls (I'm using
CakePHP, which has built-in functions to create Prototype AJAX links/
calls) and refresh the main part of the page. Facebox works fine at at
first but after you click on an AJAX link and update the content, when
you click on a facebox link it populates the facebox with multiple
copies of the content that supposed to be there (for every time you
click on an AJAX link, it adds another duplicate of the content to the
facebox). Is it because I'm using Prototype along with facebox? Are
the two incompatible? If so, is there a way around it? I'd rather not
rewrite the other menu.

strateg...@gmail.com

unread,
Jul 18, 2008, 5:36:50 PM7/18/08
to facebox
I had this problem too and found that it was caused by having multiple
copies of this line on various pages that were being loaded:
$('a[rel*=facebox]').facebox()

Ertan SAYGI

unread,
Jul 21, 2008, 11:01:52 AM7/21/08
to facebox
find this function in facebox.js file.

$.facebox.reveal = function(data, klass) {
if (klass) $('#facebox .content').addClass(klass)
$('#facebox .content').append(data)
$('#facebox .loading').remove()
$('#facebox .body').children().fadeIn('normal')
}

add

$('#facebox .content').empty()

line...It should be as following...

$.facebox.reveal = function(data, klass) {
if (klass) $('#facebox .content').addClass(klass)
$('#facebox .content').empty()
$('#facebox .content').append(data)
$('#facebox .loading').remove()
$('#facebox .body').children().fadeIn('normal')

Ketan Shah

unread,
Mar 1, 2011, 11:58:33 PM3/1/11
to fac...@googlegroups.com
one could use jquery.data() function to append some data first time facebox is init'ed. Next checks wont init facebox.

 $('a[rel*=facebox]').live("mouseup", function() {
        if($(this).data('fb') == undefined)
            $(this).facebox(faceboxOptions); // this should do, you don't need all links
        $(this).data('fb', true);
    });

Ronie Apostol

unread,
Sep 20, 2012, 11:34:13 AM9/20/12
to fac...@googlegroups.com
Multiple Copies of Content in Facebox was solved! thanks to Ertan SAYGI.. keep it up man..............

Mark Alvin Manucot

unread,
Jun 13, 2013, 5:02:30 AM6/13/13
to fac...@googlegroups.com
thanks! it works!

Vidhyalakshmi Sivabatham

unread,
Apr 9, 2015, 7:32:53 AM4/9/15
to fac...@googlegroups.com
Hi Ertan SAYGI

I searched so many solutions. But your solution is worked for me and solved the multiple copies of facebox content. You are great..

Mian Imran

unread,
Aug 19, 2015, 9:59:00 AM8/19/15
to facebox
Hi  Ertan SAYGI , i am imran. I am having the same problem (multiple copies of content in facebox and it become slower & slower each time it is reopened), I have version 1.3 of facebox ( https://github.com/defunkt/facebox ). I am seeing some different code in facebox.js, i have pasted the code here which is as follows. Kindly please guide as per the following code.

reveal: function(data, klass) {
      $(document).trigger('beforeReveal.facebox')
      if (klass) $('#facebox .content').addClass(klass)
      $('#facebox .content').empty().append(data)
      $('#facebox .popup').children().fadeIn('normal')
      $('#facebox').css('left', $(window).width() / 2 - ($('#facebox .popup').outerWidth() / 2))
      $(document).trigger('reveal.facebox').trigger('afterReveal.facebox')
    },

    close: function() {
      $(document).trigger('close.facebox')
      return false
Reply all
Reply to author
Forward
0 new messages