【发布时间】:2012-03-12 20:08:52
【问题描述】:
我正在尝试将事件侦听器添加到我的 facebook cmets 中。我可能尝试了我在 Stack Overflow、FB 开发者文档和旧开发者论坛中找到的所有内容。 评论工作正常,我也可以调节它们,但根本没有触发事件......我在一页上使用 FB cmets,带有多个 fb:cmets FBML 标签。这是我的javascript代码:
window.fbAsyncInit = function() {
FB.init({
appId: 'myAppId',
status: true,
cookie: true,
xfbml: true,
oauth: true
});
FB.Event.subscribe('comment.create',
function (response) {
console.log('create', response);
});
FB.Event.subscribe('comment.remove',
function (response) {
console.log('remove', response);
});
};
(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);
}());
还有我的 HTML:
<fb:comments class="fb-comments" href="myFirstCommentUniqueURL" data-num-posts="2" data-width="440" notify="true" migrated="1"></fb:comments>
<fb:comments class="fb-comments" href="mySecondCommentUniqueURL" data-num-posts="2" data-width="440" notify="true" migrated="1"></fb:comments>
<fb:comments class="fb-comments" href="myThirdCommentUniqueURL" data-num-posts="2" data-width="440" notify="true" migrated="1"></fb:comments>
<fb:comments class="fb-comments" href="myFourthCommentUniqueURL" data-num-posts="2" data-width="440" notify="true" migrated="1"></fb:comments>
关于 notify="true" 和 migrated="1" fb:cmets 标签参数的提示是我在 Stack Overflow 上找到的,但它们没有帮助。我还检查了是否没有多个 init 调用,但它在整个页面上也是一个。
所以我不知道,我做错了什么。
【问题讨论】:
-
如果您解决了问题,请自行回答并标记为正确。另外我建议
Shift+F5(刷新+绕过缓存)