私は本当にこれで私の頭を壊しているので、誰かが見て助けてくれることを願っています.
pushState と fb コメントを含む ajax-ed Web ページをビルドします。問題は、新しいコンテンツと fb コメントを読み込むたびに、href 属性の設定に関するエラーが発生することです。コードは次のとおりです。
まず、fb init を非同期呼び出しします。
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'MY_APP_ID',
channelUrl : 'http://promplac.si/channel.php',
status : true,
cookie : true,
xfbml : true
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +'//connect.facebook.net/en_US/all.js';document.getElementById('fb-root').appendChild(e);
}());
</script>
コンテンツの変更時に私は呼び出します:
<script>
function showComment($currentUrl) {
document.getElementById('theplace').innerHTML='<fb:comments id="fbcomment" href="'+document.URL+'" width="510" num_posts="3"></fb:comments>';
console.log(document.getElementById('theplace').innerHTML);
FB.XFBML.parse();
console.log(document.getElementById('theplace').innerHTML);
}
</script>
HTML:
<div id="theplace" class="fb-comments"><fb:comments href="" numposts='3' height='150' id="fbcomment" width="510" num_posts="3"></fb:comments></div>
例を作成しました。FB.XFBML.parse() 呼び出しの前後に、コメント用の html を console.log に入れました。この例でわかるように: http://promplac.si/nagradne-igre/nagradna-igra/izberi-oblacila-v-vrednosti-200EUR/
コメントは通常表示されますが、他のエントリをクリックすると、href 属性の設定に関する警告が表示されます。でも、コンソールを確認すると、href 属性は完全に OK ですか? 少なくとも1つのコメントがある場合、効果は発生しません...
何が間違っているのですか?