Question

Using Twitter's embed code for single tweets causes a script called widget.js to be loaded. This script is responsible for dynamically generating the HTML of the tweet.

Is there an event triggered by widget.js when the rendering of an embedded tweet is complete? How can my code find out that rendering is complete?

I need this because I am trying to use jQuery Masonry to layout a set of tweets. Masonry fixes the container height for each tweet before the tweets are fully rendered, causing overlap. I'd like to be notified that all tweets are fully rendered in order to refresh the Masonry layout.

Was it helpful?

Solution

I ended up using a jQuery "watch" plugin (e.g. https://github.com/darcyclarke/jQuery-Watch-Plugin) to watch for DOM changes on the container div.

OTHER TIPS

If you look into the uncompressed code here searching for "render" yields this interesting conditional

    if (this._rendered) {
        var anchor = this.byClass('twtr-join-conv', 'a');
        anchor.href = 'http://twitter.com/' + this._getWidgetPath();
    }

and somewhat lower in the code is

    this._rendered = true;
    // call the ready handler
    this._ready();
    return this;

you might be able to explore...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top