title: Fancybox - add link of hidden div to caption/title
body: <p>I use MODx Revo with Fancybox 2 to display images in the Lightbox-view. I have a hidden div for each image, that holds an url with a link.</p>
  
  <p>I want the link to be shown in the Lightbox-View inside the caption/title, like in this example: <a href="http://jsfiddle.net/zAe6Z/" rel="nofollow">http://jsfiddle.net/zAe6Z/</a></p>
  
  <p>So I try to change the "Download"-Link to get changed with the content of the div with the class "bildlink":</p>
  
  <pre><code>&lt;a class="album" rel="albumname" href="[[+image]]" title="[[+description]]"&gt;
  &lt;img src="[[+thumbnail]]" alt="[[+name]]" /&gt;&lt;/a&gt;
  
  &lt;div style="display:none;" class="bildlink"&gt;
  [[+url]]
  &lt;/div&gt;
  </code></pre>
  
  <p>The "variable" [[+url]] holds the url for the link that should get displayed in the Lightbox-view after the description.</p>
  
  <p>I tried this script:</p>
  
  <pre><code>$(document).ready(function() {
  
  bildlink = $('div.bildlink').html();    
  
  $(".album").fancybox({      
      cyclic : 'false',   
          afterLoad: function() {
          this.title = this.title + '&lt;a target="_blank" href="' + bildlink + '"&gt;' + bildlink + '&lt;/a&gt; ';
      },
      helpers : {
          title   : { type: 'inside' }
      },      
      });         
  });
  </code></pre>
  
  <p>By using this script the Link get's changed, but it uses the same link/url of the first item for each item, it's not related to the clicked-element or to the child-div "bildlink" or the clicked-element.</p>
  
  <p>Here's a fiddle for that: <a href="http://jsfiddle.net/gEYtB/" rel="nofollow">http://jsfiddle.net/gEYtB/</a> (EDIT: <a href="http://jsfiddle.net/gEYtB/2/" rel="nofollow">http://jsfiddle.net/gEYtB/2/</a>)</p>
  
  <p>So how do I get the content of the div "bildlink" of the clicked-element and use this for the link? </p>
  
  <p>Any hints much appreciated!</p>
  
  <p>EDIT: Have been researching and trying a lot, but no luck so far...i thought the "bildlink" must be written new on each click of an element, so i tried to implement it inside the "afterLoad"-function:</p>
  
  <pre><code>$(document).ready(function() {  
  
  $(".album").fancybox({      
      cyclic : 'false',   
          afterLoad: function() {
          bildlink = $this.next('div.bildlink').html();
          this.title = this.title + '&lt;a target="_blank" href="' + bildlink + '"&gt;' + bildlink + '&lt;/a&gt; ';
      },
      helpers : {
          title   : { type: 'inside' }
      },      
      });         
  });
  </code></pre>
  
  <p>But this didn't work...</p>