ajax - Javascript facebook comments too many refreshes -


i have page kind of infinite scrolling. means homepage loads n posts everytime user reach bottom of page. every post has facebook comments loaded xfmbl way: after ajax had loaded post, following script parse facebook plugin:

$( document ).ready(function() {                     fb.xfbml.parse(document.getelementbyid("<?php echo $_id ?>"), function() {});                 }); 

actually "infinite scrolling" not give me problems beginning. in fact when load whole page, supposing site firstly load 5 posts fill screen, every facebook comments refreshed 5 times. after have no other problems (every post loaded later doesn't give problems).

can me? in advance

based on answer:

fb.xfbml.parse() on individual element nothing

what can following:

on success callback (when requesting new posts), first, create unique id posts. in above example, can use:

newdivname = "d" + string(new date().valueof()); 

then cache newly requested post (again, same example):

var $newhtml = $("<div id='" + newdivname + "'>" + html + "</div>"); 

append wherever have to; , finally, using unique id, can do:

fb.xfbml.parse($newhtml[0]); 

basically, previous mentioned question should solve question.

now, depends on infinite scroll plugin using, sure have success callback can place code. don't know if access every post individually or ajax request return posts in row. have reach point can identify each single of post, can refresh them individually, , parse xfbml markup on fly individually, wont load more times needed.

hope helps !


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -