title: Adding Pinterest image hover widget after Ajax load
body: <p>I am using the pinterest image hover widget to add the ability for users to pin images off my website to their pinterest accounts. </p>
  
  <p>Widget found here: <a href="http://business.pinterest.com/widget-builder/#do_pin_it_button" rel="nofollow">http://business.pinterest.com/widget-builder/#do_pin_it_button</a>
  (Click the image hover radio button under button type to see the one I am using.)</p>
  
  <p>I have the pinterest button working fine on other pages on the website where no ajax is used to load any content using the code provided by pinterest:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  (function(d){
  var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT');
  p.type = 'text/javascript';
  p.setAttribute('data-pin-hover', true);
  p.async = true;
  p.src = '//assets.pinterest.com/js/pinit.js';
  f.parentNode.insertBefore(p, f);
  }(document));
  &lt;/script&gt;
  </code></pre>
  
  <p>However where I am encountering a problem is when I am loading some content in a popup window via ajax and I need to have a pinterest button load with that content. I have tried not loading the pinterest code until the ajax request is complete but am having no luck so far. Have tried this:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  jQuery(document).ajaxComplete(function() {
      (function(d){
       var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT');
       p.type = 'text/javascript';
       p.setAttribute('data-pin-hover', true);
       p.async = true;
       p.src = '//assets.pinterest.com/js/pinit.js';
       f.parentNode.insertBefore(p, f);
       }(document));
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>I am not loading the pinterest code anywhere else on this page until using the above method to load after ajax has inserted the extra content into the DOM. I have also tried a few other method's I have found it other topics around the interent but none have helped. I have not been able to find any other solutions that work specifically with the image hover widget so if anyone has had any luck with using it with Ajax before any advice would be awesome.</p>
  
  <p>Thanks :)</p>