How do I call a callback when a Twitter widget is rendered?
Using the code they provided:
TWTR.Widget({data: something}).render().setUser('me').start();
Twitter has notoriously spotty service and frequent long load times. How do I add a callback on loading of the TWTR widget, so I can show my users a loader in the meantime?
The widget has a _rendered
property.
I made an example on jsfiddle. Note that there is no callback, you have to poll it to check if it has rendered. Also, you have to assign it to a variable when you create it, so you can access the _rendered
property.
I found this by jsbeautifying the script, so it might not be 100% trustworthy and definitely not supported.
I had to hunt down the author of the library on Twitter, but there is a ready
callback:
E.g.
new TWTR.Widget({
id: 'twitter-feed',
version: 2,
.
.
.
features: {
scrollbar: false,
.
.
},
ready: function() {
jQuery("div#twitter-load").remove();
}
}).render().setUser('me').start();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With