fancyBox + Wordpress - open gallery with couple of images manually

177 views
Skip to first unread message

bivvo

unread,
Aug 26, 2012, 12:39:20 PM8/26/12
to fanc...@googlegroups.com

Hi there,

I've found a nice solution, I would like to implement on my website, too: http://jsfiddle.net/uZCC6/1/

I gave that a try here: http://goo.gl/zXWF7 (bottom left, the link behind the point ".").

The code I've integrated in the header is:

jQuery(".open_fancybox").click(function() {
    jQuery.fancybox.open([
        {
            href : 'http://fancyapps.com/fancybox/demo/1_b.jpg',                
            title : '1st title'
        },
        {
            href : 'http://fancyapps.com/fancybox/demo/2_b.jpg',                
            title : '2nd title'
        },
        {
            href : 'http://fancyapps.com/fancybox/demo/3_b.jpg',                
            title : '3rd title'
        }
    ], {
                prevEffect      : 'none',
                nextEffect      : 'none',
                closeBtn        : false,
                helpers     : {
                        title   : { type : 'inside' },
                        buttons : {}
                }
    });
    return false;
});

... and trying to call the method with:

<a href="http://fancyapps.com/fancybox/demo/1_b.jpg" class="open_fancybox">.</a>

Does anyone can help me, why the images are not opened within the lightbox?

Thx & kind regards

JFK

unread,
Aug 27, 2012, 2:51:59 AM8/27/12
to fanc...@googlegroups.com
the jQuery(".open_fancybox").click() should be also INSIDE the jQuery(document).ready() method
additionally, you are nesting a jQuery(document).ready() method inside another like

jQuery(document).ready() 
    function() {
        jQuery('.fancybox').fancybox();
        jQuery(document).ready(function() {...

you functions should be like

jQuery(document).ready(function(){
 jQuery(".fancybox-buttons").fancybox({
  // fancyboxAPI options here
 }); // first fancybox

 jQuery(".open_fancybox").click(function() {
  jQuery.fancybox.open(
   [// group of images],
   { 
    // fancybox API options here
   }
  ); // second fancybox
 }); // click
}); //ready 

bivvo

unread,
Aug 27, 2012, 5:05:17 PM8/27/12
to fanc...@googlegroups.com
Thx, that worked great!
Reply all
Reply to author
Forward
0 new messages