title: Wiring Facebook HTML5 like and comment elements with AJAX
body: <p>Facebook instructs us to put the following code on our page:</p>
  
  <pre><code>&lt;div id="fb-root"&gt;&lt;/div&gt;
  &lt;script&gt;(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));&lt;/script&gt;
  </code></pre>
  
  <p>Instead of that I wrap it in a function:</p>
  
  <pre><code>function ReloadSocialSharing() {
      //facebook
      (function (d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) return;
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&amp;appId=myappid";
          fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
  }
  </code></pre>
  
  <p>and call it inside: <code>$(function () { }</code></p>
  
  <p>Now my like buttons and my Comment via Facebook panels all appear and work fine. I then make an AJAX call and pull in new html elements into my page. These already have the appropriate Facebook markups similar to what my original fields had. I make my ajax call like this:</p>
  
  <pre><code>$('#search').ajaxSubmit(GetSearchAjaxFormOptions(!isDefault, element));
  
  function GetSearchAjaxFormOptions(displayResetPreferencesButton, giveMeFocus) {
      return {
          target: '#search-results',
          data: GetSearchData(),
          success: function () { RunAfterSearchResultsAreReturned(giveMeFocus) },
          error: function (error) {
              alert("Oops. There was an error.")
          }
      };
  }
  
  RunAfterSearchResultsAreReturned() {
     ........
     ReloadSocialSharing();
  }
  </code></pre>
  
  <p>This all executes well, however, the new social sharing elements that were added in via the Ajax call are not wired and do not work.  What am I missing?</p>
  
  <p>Thanks!</p>
  
  <p>Note: I have seen the notes on using FB.XFBML.parse(); However, I am trying to avoid XFBML.</p>