I have two different mechanisms on my site using both xfbml and fbjs:
- an FB:Like tag for individual entries
- the FB object for facebook logins with fb connect
My problem is when I include “all.js” on the page, the login script works but the fb:like tag doesn’t work.
When I include “all.js#xfbml=1”, the fb:like tags work again, but now my FB object is undefined and my login code doesn’t work.
Is there something I’m missing?
Thanks in advance for any help you can give.
You only need to include the script reference one time and call init on the script when the page is loaded. You can use this for either the fb:like buttons or the login script.
The key to this is setting the xfbml to true (this is what the #xfbml=1 does). If you dont have that set then the like buttons wont render.
If you want to subscribe to the login event just add the following script after the FB.init() call:
And here would be your login script to be fired ONLY when a user clicks on a link, button, etc.