开发者

FB.ui does not work the first time. Help!

I created an app which publishes to the user's wall. The problem is, the first time the user ac开发者_JAVA百科cesses the page, the FB.ui doesn't show up. After one reload, it works perfectly.

by first time, I mean when the user gives permissions to the app, OR when he has already given permissions. In both scenarios, the problem occurs. Any ideas, people?

FB.init({
  appId  : "XXXX",
  status : true,
  xfbml  : true,
  cookie : true
});
FB.ui(
{
 method: 'stream.publish',
 message: 'test message'
      }
);


This is a frequent problem in JS, with things like trying to calculate how far an item has moved, and it only starts counting after the first iteration.

You need to wrap your js in window.onload = function() {

}

Although this is buggy cross-browser, and may not fix issue. Have you heard of jQuery, its:

$(document).ready(function() {
}

If a very robust solution to ths problem


Comment #70 by Will Kessler at: http://bugs.developers.facebook.net/show_bug.cgi?id=12849 fixed my problem. It's a hack, but it works perfectly :) I had another bug related to this ( FB.ui does not work inside FB canvas. HELP!) , and it also was fixed using this. FB API is seriously buggy! :|

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜