Search code examples
fancyboxfacebook-javascript-sdkfacebook-sharer

Facebook share button not working inside Fancybox


I got the code for the Facebook share button code right from facebook, it is as this:

<div class="fb-share-button" data-href="http://example.com/item/sharefb/47"></div>

While on a regular page, it works fine. It renders it assyncrhonously and for each item on the page working great.

But inside a fancybox ajax call, the button simply won't work. Facebook API will not process it, and the div will not turn into facebook's iframe full of stuff.

Any hints?


Solution

  • You need to parse the button after opening the box:

    FB.XFBML.parse();
    

    Source: https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse