Changing the caption attribute combines multiple galleries on a webpage into one gallery

33 views
Skip to first unread message

Saul Baizman

unread,
Jun 29, 2013, 8:16:46 PM6/29/13
to fanc...@googlegroups.com
Hi there,

I'm using fancybox 2.1.4.

Following the instructions on the page below (linked to from http://fancyapps.com/fancybox/#useful):


I changed the caption attribute from 'title' to 'caption.' However, when I have multiple galleries on a single webpage, for some reason all of the elements in the galleries are lumped together into one mega gallery.

Here's an example:

There are clearly two galleries on the page ('1' and '2').

When you click on an image and browse the set, there should be two sets of 2 images. Instead, there's 1 set of 4 images.

While I'm not asking anyone to outright solve/fix this issue, can someone point me in a direction as to where to begin debugging the problem?

Thank you.

-Saul

JFK

unread,
Jun 30, 2013, 1:13:59 AM6/30/13
to fanc...@googlegroups.com
Yes, every gallery has its own rel attribute, however if your do this
$(".fancybox")
   
.attr('rel', 'gallery')
   
.fancybox({
        beforeLoad
: function() {
           
this.title = $(this.element).attr('caption');
       
}
   
});

that will override the rel attribute for all the links with class fancybox.

Just change remove the part `.attr('rel', 'gallery')` like
$(".fancybox")
   
.fancybox({
        beforeLoad
: function() {
           
this.title = $(this.element).attr('caption');
       
}
   
});

and it will work as expected

Saul Baizman

unread,
Jun 30, 2013, 10:12:45 PM6/30/13
to fanc...@googlegroups.com
Thanks for your response. It worked like a charm! Time to seriously invest in some jquery tutorials... 
Reply all
Reply to author
Forward
0 new messages