Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7674081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:39:36+00:00 2026-05-31T16:39:36+00:00

I initialize the tweet button at the beginning of my app, after user interaction

  • 0

I initialize the tweet button at the beginning of my app, after user interaction the current window’s location is updated using HTML5 pushState, but the twitter button is still sharing the previous URL from when it was initialized.

How do I update the URL that twitter uses?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:39:37+00:00Added an answer on May 31, 2026 at 4:39 pm

    I figured this out. Here’s how to make this work.

    The general idea is:

    1. In your HTML set the class of your <a> for the twitter share button to be something other than .twitter-share-button. Also give the <a> a style="display:none;".
    2. In your HTML, where you want the twitter share button to appear, create a <div> (or <span>) with a unique id.
    3. In your jQuery, when you want to set the data for the twitter share button you will:
      • ‘clone()the hidden, mis-named,` tag from step #1
      • On this clone, set the data-url etc… attributes as you’d like
      • Remove the style attribute from the clone (unhide it)
      • Change the class of the clone to twitter-share-button
    4. append() this clone to your <div> from step 2.
    5. Use $.getScript() to load and run Twitter’s Javascript. This will convert your cloned <a> into an <iframe> with all the right goop.

    Here’s my HTML (in Jade):

      a.twitter-share-button-template(style="display:none;", href='https://twitter.com/share=', data-lang='en',
          data-url='http://urlthatwillbe_dynamically_replaced',
          data-via='ckindel', data-text='Check this out!',
          data-counturl='http://counturlthatwillbe_dynamically_replaced') Share with Twitter
        #twitter-share-button-div
    

    Then in your client-side .js:

    // the twitter share button does not natively support being dynamically
    // updated after the page loads. We want to give it a unique (social_id)
    // link whenver this modal is shown. We engage in some jQuery fun here to 
    // clone a 'hidden' twitter share button and then force the Twitter
    // Javascript to load.
    
    // remove any previous clone
    $('#twitter-share-button-div').empty()
    
    // create a clone of the twitter share button template
    var clone = $('.twitter-share-button-template').clone()
    
    // fix up our clone
    clone.removeAttr("style"); // unhide the clone
    clone.attr("data-url", someDynamicUrl); 
    clone.attr("data-counturl", someDynamicCountUrl);
    clone.attr("class", "twitter-share-button"); 
    
    // copy cloned button into div that we can clear later
    $('#twitter-share-button-div').append(clone);
    
    // reload twitter scripts to force them to run, converting a to iframe
    $.getScript("http://platform.twitter.com/widgets.js");
    

    I got the main clues for this solution from here:
    http://tumblr.christophercamps.com/post/4072517874/dynamic-tweet-button-text-using-jquery

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a WP7 app that would Tweet short messages user
def initialize(apps, catch=404) @apps = []; @has_app = {} apps.each { |app| add app
I need to initialize private readonly field after Deserialization. I have folowing DataContract: [DataContract]
I initialize an activity indicator and in a button press action I start it
When initialize an entity framework context. One is to initialize at class level, such
To initialize an int array with all zeros, do I need to use: int
How do I initialize an automatic download of a file in Internet Explorer? For
In C++ you can initialize a variable in an if statement, like so: if
In spring you can initialize a bean by having the applicationContext.xml invoke a constructor,
How can I initialize a const / static array of structs as clearly as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.