0
votes

i have the fancybox thumbnail helper example working from http://fancyapps.com/fancybox

currently the gallery opens when i click one of the thumbnails.

I would rather not have the thumbnails already existant on the page. the links will instead be loaded into the DOM via ajax into a hidden div and I want to manually open the gallery at that point.

<a id="sketches_link">see sketches</a>

<div id="sketches_data" style="display:none;">
  my links will be loaded here....
  <a class="fancybox-thumb" href="someimage.jpg" rel="fancybox-thumb"></a> 
</div>

<script>
  $(document).ready(function() {


   $("#sketches_link").click(function() {
     $("#sketches_data").load("sketches.php", function() {
       $(".fancybox-thumb").fancybox({ 
         helpers : { 
           thumbs : { 
             width: 50, 
             height: 50 
         } // thumbs 
        } // helpers 
      }); // fancybox  
     });   //load
     });//click

   });//ready

  /*****NOW THE BINDING IS READY, BUT HOW TO I AUTOMATICALLY OPEN
    THE GALLERY AFTER THE ON CLICK EVENT?******/
</script>
1

1 Answers

0
votes

I got it to work by triggering a click event on the first link in the ajax downloaded sequence of links. Not elegant but it works.