How to render facebook comment plugin after ajax?

in header

<meta property="fb:admins" content="my id"/> 
<meta property="fb:app_id" content="my api"/>

And in body

 <div id="fb-root"></div>
        <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/ru_RU/all.js#xfbml=1&appId=my api";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));</script>

In html

<div id="facebook">
<div class="fb-comments" data-href="<?= $this->productLink ?>" data-width="470" data-num-posts="10"></div>
    </div>

I find problem-i load my web page with ajax and that facebook code don't work with ajax. How render my facebook comments after ajax? Execute that function?

Upvotes: 3

Views: 5063

Answers (1)

Soojoo
Soojoo

Reputation: 2156

Add the following javascript code just below the ajax for showing facebook comment plugin.

FB.XFBML.parse();

Refer:http://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse/

Upvotes: 21

Related Questions