Javascript 如何让Yammer嵌入提要事件侦听器工作?
从中,您需要钩住Yammer嵌入提要事件的全部内容是使用:Javascript 如何让Yammer嵌入提要事件侦听器工作?,javascript,events,embed,yammer,listeners,Javascript,Events,Embed,Yammer,Listeners,从中,您需要钩住Yammer嵌入提要事件的全部内容是使用: yam.on(eventId, callbackFunction, [context]); 我使用他们提供的EventID完成了这项工作,因此我的代码最终如下所示: <script type="text/javascript"> yam.connect.embedFeed({ container: "#embedded-comments", network: "mynetwork
yam.on(eventId, callbackFunction, [context]);
我使用他们提供的EventID完成了这项工作,因此我的代码最终如下所示:
<script type="text/javascript">
yam.connect.embedFeed({
container: "#embedded-comments",
network: "mynetwork",
feedType: "open-graph"
});
function alertMe() {
alert("Loading Completed!");
}
var nothing = "";
yam.on('/embed/feed/loadingCompleted', alertMe(), nothing);
</script>
yam.connect.feed({
容器:“#嵌入注释”,
网络:“我的网络”,
feedType:“开放图形”
});
函数alertMe(){
警报(“加载完成!”);
}
var nothing=“”;
yam.on('/embed/feed/loadingCompleted',alertMe(),nothing);
只有alertMe()
函数在页面加载之前立即被调用。将eventID更改为无效显示了相同的行为,因此我开始认为我遗漏了一些东西
知道什么会导致事件立即触发吗?通过将alertMe作为引用传递(删除括号)使其正常工作。我看到这些事件在被读取的同时被执行,因此它们会立即触发 这是一个愚蠢的错误,但作为一名javascript初学者,我肯定会犯很多这样的错误:)试试这个
yam.on('/embed/feed/loadingCompleted', alertMe, nothing);