2012-01-06 13 views
0

次のコードを書くと、FBが未定義になります.Windows.fbAsyncInitを使用してFacebookに必要なファイルが正常に追加されました。それはうまく動作しますが、jquery mobileのページショーではうまくいきません。これは、Facebookのjsファイルが少し遅れて読み込まれているために起こっている可能性があります。しかし、私はすべてのページで不必要なアクセスや匿名アクセスを制限するためにユーザーの状態を確認したい。FBが未定義のときに表示されます。

$("#details").live("pageshow", function() { 

      FB.getLoginStatus(function(response) { 
       if (response.status === 'connected') { 
       // the user is logged in and connected to your 
       // app, and response.authResponse supplies 
       // the user's ID, a valid access token, a signed 
       // request, and the time the access token 
       // and signed request each expire 
       var uid = response.authResponse.userID; 
       var accessToken = response.authResponse.accessToken; 

       console.log("INSIDE ME"); 
       } else if (response.status === 'not_authorized') { 
       // the user is logged in to Facebook, 
       //but not connected to the app 
       console.log("OUTSIDE ME"); 
       } else { 
       // the user isn't even logged in to Facebook. 
       } 
     }); 

}); 

答えて

0

window.fbAsyncInit内にjQueryのlive()割り当てを配置します。このようにして、FBが初期化する機会を得た後で、それはDOM要素にのみ適用されます。

関連する問題