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 7954309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:23:27+00:00 2026-06-04T03:23:27+00:00

This question comes very closely to what I’m after: Replace an Attribute in the

  • 0

This question comes very closely to what I’m after: Replace an Attribute in the Tweet Button with Jquery

However, the suggested solution works just once. That is, I cannot use it in my switch statement like this:

    switch(element.id)
    {
        case "t1":
            $(document).ready(function(){
                $('a[data-text]').each(function(){
                    $(this).attr('data-text', Text_Variant_1);
                });
                $.getScript('http://platform.twitter.com/widgets.js');
            });
            break;
        case "t2":
            $(document).ready(function(){
                $('a[data-text]').each(function(){
                    $(this).attr('data-text', Text_Variant_2);
                });
                $.getScript('http://platform.twitter.com/widgets.js');
            });
        ...
    }

What happens is that the data-text attribute is set according to whichever case happens first and doesn’t change afterwards.

How can I change data-text attribute of a Tweet Button as many times as I need?

Update: here’s the page I’m working on: http://zhilkin.com/socio/en/

The Traits table can be safely ignored. What I want to do with the Sociotypes table is that when you click on a type, the data-text of the Tweet Button below the description on the right should be changed accordingly.

Right now it works like this: if I hover on or click “Don Quixote”, then data-text is set to “… Don Quixote …”, and it stays the same if I click “Dumas” later. And vice versa: if I hover on or click “Dumas”, then data-text is set to “… Dumas …” and doesn’t change if I click “Don Quixote”. (Other types are empty at the moment.)

So, the Tweet Button is only changed the first time I run the script, but I need it to be updated as many times as the type changes.

  • 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-06-04T03:23:29+00:00Added an answer on June 4, 2026 at 3:23 am

    I struggled with this for a couple of hours this morning, but finally got it working! The problem is essentially that you can only include the twitter widgets.js script once in the page, and that script evaluates the data-text attribute on load. Therefore, in your example, you dynamically set the data-text attribute before loading the script, which will work as expected. However, you can then make no further updates as the script has already run.

    I saw this article suggesting you can call twttr.widgets.load() again at runtime to re-evaluate and re-render the buttons, however that didn’t work for me. This is because that function re-evaluates <a> tags, not <iframe> tags!

    So the solution, as pointed out here, is to completely remove the rendered <iframe> from the DOM, then make a new <a> element with all the appropriate attributes before calling twttr.widgets.load() to finally re-evaluate it and turn it into an <iframe>.

    Please see this fiddle for a working example!

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

Sidebar

Related Questions

This question comes up after reading a comment in this question: Database Design When
Okay, this question comes through a friend so it might be lost in translation...
( Late edit: This question will hopefully be obsolete when Java 7 comes, because
Check this example before reading the question - http://www.sqlfiddle.com/#!2/fcf3e/8 The following data comes from
This is very similar to a question I asked the other day but my
This question might appear very simple, but i haven't found an answer yet, so
This question may look to be very simple but i don't know the answer.
This question is very similar to that posed here . My problem is that
This question may be very similar to my one, but I cannot see the
I have a VERY similar question to this question: ASP.NET MVC C# dynamic radiobuttons

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.