页面上的所有Twitter推文都呈现了事件/回调

时间:2015-03-19 19:10:20

标签: javascript jquery twitter tweets

我正在使用此code

twttr.ready(function (twttr) {
    // At this point the widget.js file had been loaded.
    // We can now make use of the twttr events
    twttr.events.bind('rendered', function (event) {
         // At this point the tweet as been fully loaded
         // and rendered and you we can proceed with our Javascript
        console.log("Created widget", event.target.id);
    });
});

不幸的是,'呈现了'每个推文都会单独触发事件,是否有正确的方法在呈现/显示页面上的所有页面上的嵌入推文时通知?

1 个答案:

答案 0 :(得分:0)

好的,我找到了合适的解决方案。您需要侦听'loaded' event,这只会在显示所有推文小部件后触发。

twttr.ready(function (twttr) {
    // At this point the widget.js file had been loaded.
    // We can now make use of the twttr events
    twttr.events.bind('loaded', function (event) {
         // At this point all tweets have been fully loaded
         // and rendered and you we can proceed with our Javascript
        console.log("Created widget", event.target.id);
    });
});