I'm using a twitter widget that uses twitter api http://widgets.twimg.com/j/2/widget.js to bring in the latest tweet from my twitter. along the bottom the widget has three links 'reply · retweet · favorite' i need to correct 'favorite' so that its in the british spelling( 'f开发者_如何学Cavourite') with a 'u' in it. i thought i could do this with jquery:
$(window).load(function () {
$(".twtr-fav").text('Favourite');
});
but this doesnt seem to work. any ideas?
I looked through the code. This is a templating system with no callback when it adds something new. I can't think of any sort of events that it will automatically fire when it adds something...
Your best bet will likely be to patch (urk) the source code. I'd start from the official base documented twitter code: http://twitter.com/javascripts/widgets/widget.js
It is a simple one-line change (on line 789), but it can't be monkey patched because there isn't a global object (exactly why I hate that style of function wrapping).
Would be overjoyed for anyone to point out the holes in my logic or knowledge base, but that's how I see it.
Added:
I figured out what was gnawing at the back of my mind... there is a way to detect when dom nodes are added:
document.addEventListener('DOMNodeInserted',favoriteChanger);
You probably want to call that only after everything is up & running on the site... and you'll need to put a check into favoriteChanger to handle only events that are coming through that are children of the target widget (as ANY object will show up otherwise). Also, you may have issues on downlevel IE.
精彩评论