开发者

FBML elements rendering delay

I am using FBML for rendering certain elements on the page such as the name of the user, profil pic, etc. However when there are many FBML elements on page, there is a slight delay which occurs before they are rendered - that's fine since AJAX calls are made to the server to fetch the data by t开发者_StackOverflow中文版he JS FB library. However, I want to hide the container DIV holding these element till the elements have finished loading, so is there any way to specify a JS callback function which gets fired when the FBML data has finished loading?


Try FB.Event.subscribe

FB.Event.subscribe('xfbml.render', function(response) {
  //xfbml.render is fired when a call to FB.XFBML.parse() completes
});


There is another option for this. First, make sure you have the xfbml=0 parameter set on all embeds. Next, you can use this small bit of jQuery:

window.fbAsyncInit = function(){
  FB.XFBML.parse(null,function(){
      // all FB embeds are rendered as of this point
  });
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜