Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook commenting w/Rails 4 and Turbolinks
    text
    copied!<p>I'm having trouble adding Facebook social plugins (specifically commenting) to my Rails 4 app with Turbolinks enabled. I followed the example on <a href="https://github.com/rails/turbolinks/issues/62" rel="nofollow noreferrer">turbolinks issue #62</a>, but couldn't get it to work.</p> <p>I also tried turbolink's solution <a href="http://reed.github.io/turbolinks-compatibility/facebook.html" rel="nofollow noreferrer">here</a>, but couldn't get it to work.</p> <p>Fixing the apparent typo on the turbolinks page per <a href="https://stackoverflow.com/a/18112911/1839944">this answer</a> did not work either.</p> <p>The SDK isn't loading and there are no errors in the console.</p> <p>Code:</p> <pre><code>### view: &lt;div id="fb-root"&gt;&lt;/div&gt; &lt;div class="fb-comments" data-href="&lt;%= request.original_url %&gt;"&gt;&lt;/div&gt; ### coffeescript: fb_root = null fb_events_bound = false $ -&gt; loadFacebookSDK() bindFacebookEvents() unless fb_events_bound bindFacebookEvents = -&gt; $(document) .on('page:fetch', saveFacebookRoot) .on('page:change', restoreFacebookRoot) .on('page:load', -&gt; FB.XFBML.parse() ) fb_events_bound = true saveFacebookRoot = -&gt; fb_root = $('#fb-root').detach() restoreFacebookRoot = -&gt; if $('#fb-root').length &gt; 0 $('#fb-root').replaceWith fb_root else $('body').append fb_root loadFacebookSDK = -&gt; window.fbAsyncInit = initializeFacebookSDK $.getScript("//connect.facebook.net/en_US/all.js#xfbml=1") initializeFacebookSDK = -&gt; FB.init appId : 'xxxxxxxxxxxx' channelUrl: '//www.mydomain.com/channel.html' status : true cookie : true xfbml : true ### /public/channel.html &lt;script src="//connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt; </code></pre> <p>--</p> <p>Thanks. Really appreciate the help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload