开发者

Updating the Tweet This location after an Ajax call

I have a small routine which pulls out small snippets of news articles and a "Tweet This" button associated with the relevant article.

On the left of the page, I have a title of the article, clicking on it loads the main article to the right.

The problem I have however is that the "Tweet This" button always keeps the same URL as when the page loaded.

Is there anyway to d开发者_开发知识库ynamically change the location of the "Tweet This"?

I've tried using this code:

$('#content').find('a.twitter-share-button').each(function()
{
   var tweet_button = new twttr.TweetButton( $( this ).get( 0 ) );
   tweet_button.render();
});

But that's not working at all.


How are you loading the content in the pane to the right? If it's just a normal link, might it be worth changing this to small ajax call which loads the content instead? That way you can also update your "Tweet this" button, simply by adding the relevant code into the success callback for your ajax call.

Alternatively, debug the code you have above: (1) how / where do you run it? (If it's running on initial page load, obviously it won't update right); and (2) check that this refers to the right thing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜