Last week, I added Facebook and Twitter sharing buttons to my rails app. I thought they were working fine, but it seems like they are not securely loaded and require updates to show them. I thought this was a problem with turbolinks, as this often happens, so I installed jquery-turbolinks'em. This is not a problem with turbolinks.
After inspecting, I found answers such as this and adding twttr.widgets.load(); at the end of my Twitter function, solved this problem, I was out of luck with getting FB.XFBML.parse(); to make the share share button to download without updating. On this On the Facebook page, the sharing button does not appear as one of the things that can be fixed using this code.
My code, which is in partial, is as follows:
<script>(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/sdk.js#xfbml=1&version=v2.0"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); FB.XFBML.parse();</script> <div class="share-buttons"> <div id="fb-root"></div> <div class="fb-share-button" data-href="#{request.original_url}" data-width="110"></div> </div>
javascript ruby-on-rails facebook ruby-on-rails-4 facebook-sharer
Ossie
source share