title: Aftershow in fancybox jQuery
body: <p>I had the same problem this person: <a href="https://stackoverflow.com/questions/12923229/sharethis-plugin-not-working-in-fancybox-title/12943117#12943117">ShareThis plugin not working in FancyBox title</a> But now I have gotten it work, except the</p>
  
  <pre><code>afterShow: function(){
   stButtons.locateElements();
  }
  </code></pre>
  
  <p>Where in this code should I put it? I've tried many places, but it just says error. It say's I am placing it wrong. Where should I place it in the script below?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  
  
  $(document).ready(function(){
      $(".fancybox").fancybox({
  
  
               beforeShow: function() {
   var caption =  $(this.element).data("caption") ? $(this.element).data("caption") : "";
   this.title = this.title ? this.title + buildShareThis(this.href) + caption : buildShareThis(this.href) + caption;
  
  
  
          if (this.title) { ''
  
          // New line
              this.title += '&lt;br /&gt;';
  
  
  
          }
      },
  
  
  
  
          nextEffect  : 'fade',
  prevEffect  : 'fade',
  padding     : 0,
  margin      : [15, 15, 50, 15],
  afterLoad   : addLinks,
  beforeClose : removeLinks
  
          });
  
  
        function buildShareThis(url){
  var customShareThis  = "&lt;div class='share'&gt;"; // class for styling maybe
   customShareThis += "&lt;span class='st_facebook_hcount' displayText='Facebook' st_url='"+url+"'&gt;&lt;/span&gt; ";
   customShareThis += "&lt;span class='st_twitter_hcount' displayText='Tweet' st_url='"+url+"'&gt;&lt;/span&gt;";
   customShareThis += "&lt;span class='st_pinterest_hcount' displayText='Pinterest' st_url='"+url+"' st_img='"+url+"' &gt;&lt;/span&gt;";
   customShareThis += "&lt;span class='st_tumblr_hcount' displayText='Tumblr' st_url='"+url+"'&gt;&lt;/span&gt;";
   customShareThis += "&lt;/div&gt;";
   return customShareThis;
  }
  
      function addLinks() {
  var list = $("#links");
  
  if (!list.length) {    
      list = $('&lt;ul id="links"&gt;');
  
      for (var i = 0; i &lt; this.group.length; i++) {
          $('&lt;li data-index="' + i + '"&gt;&lt;label&gt;&lt;/label&gt;&lt;/li&gt;').click(function() {     $.fancybox.jumpto( $(this).data('index'));}).appendTo( list );
      }
  
      list.appendTo( 'body' );
   }
  
  list.find('li').removeClass('active').eq( this.index ).addClass('active');
  }
  
  function removeLinks() {
  $("#links").remove();    
  }
  
  });
  
  &lt;/script&gt;
  </code></pre>