0

I'm creating a infinite scroll on home page ... and every post have fb share and like button everything is working good but the only problem is not getting the FB like Button on new post(Coming through AJAX) ...

<div class="fb-like" data-href="<?php echo get_permalink($page["ID"]); ?>" data-width="The pixel width of the plugin" data-height="The pixel height of the plugin" data-colorscheme="light" data-layout="button_count" data-action="like" data-show-faces="false" data-send="false"></div> 

this the code used by me for fb-like ...

3
  • you should initiate the fb like button after the new data render on the page. You have to use this to parse the Social Plugins, right after loading the AJAX content: Commented Nov 29, 2013 at 4:58
  • but how as its coming from ajax Commented Nov 29, 2013 at 4:59
  • 1
    You have to use this to parse the Social Plugins, right after loading the AJAX content: developers.facebook.com/docs/reference/javascript/… FB.XFBML.parse(); Make sure the JavaScript SDK is loaded before using AJAX, it´s best to use this code: developers.facebook.com/docs/reference/javascript Right where it says "Additional initialization code" you can use AJAX, that´s when the JavaScript SDK will be loaded. Commented Nov 29, 2013 at 5:03

1 Answer 1

1

Use below method in response to ajax request right after the append method.

FB.XFBML.parse();

To reparse the fb link within the div use below method.

FB.XFBML.parse(document.getElementById('foo'));

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.