Reputation: 1411
I'm using Rails 4 with Turbolink and want to integrate Facebook Javascript SDK. If turn off Turbolink, everything seems okay. But when not, this error always appears when I call FB.ui:
Uncaught Error: element not specified all.js:82
This can be solved if I refresh the page.
Before this error, I have solved "FB not defined" error by this code:
window.fbAsyncInit = function() {
$(function() {
FB.init({
...
})
});
}
and Facebook JS SDK is got by:
<script src='//connect.facebook.net/en_US/all.js'></script>
I have read a lot of relative questions and answers but still haven't had solutions for this issue. How to solve this issue?
Upvotes: 0
Views: 234
Reputation: 2312
The reason is Turbolink doesn't reload all stylesheet when loading a new page. You can make a function, then every time the page load, this function will be call again
fb_register = ->
# Your code here
And then, add this below
$(document).ready(fb_register)
$(document).on('page:load', fb_register)
Upvotes: 1