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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:31:29+00:00 2026-05-22T18:31:29+00:00

I am trying to add an option to a profile page for twitter widget

  • 0

I am trying to add an option to a profile page for twitter widget and I have a field where users can add their twitter accounts and below it shows a preview of the widget. It works fine if I enter an account and click save and come back. But what I am trying to do is make it dynamic, to refresh the widget with corresponding account when blur event occurs on the text-field.

I have the following code:

var twitterWidget = new TWTR.Widget({
  version: 2,
  type: 'profile',
  rpp: 4,
  interval: 6000,
  width: 'auto',
  height: 300,
  theme: {
    shell: {
        background: '#cccccc',
        color: '#333333'
        },
    tweets: {
        background: '#ffffff',
        color: '#333333',
        links: '#0099cc'
        }
  },
  features: {
    scrollbar: false,
    loop: false,
    live: false,
    hashtags: true,
    timestamp: true,
    avatars: true,
    behavior: 'all'
  }
});
twitterWidget.setUser(twitterUser).render().start();

    $('#twitter_widget_id').change(function(){          
        twitterWidget.setUser($(this).val()).render().start();
    });

In this case it works wrong: it shows only the newest tweets from all the accounts that I entered and in general I’m getting an empty widget.

If I delete the object and create a new one it makes the page blank and then adds the widget.

Does anyone know some public methods for the TWTR.Widget() like re-render() or something like that?

Thanks.

  • 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-22T18:31:30+00:00Added an answer on May 22, 2026 at 6:31 pm

    The documented Twitter widget source code is available at http://twitter.com/javascripts/widgets/widget.js and reading through it will tell you everything you need to know about how to manipulate its behavior. Briefly, the widget works like this:

    When the widget is first created with new TWTR.Widget it calls .init() and takes note of where it’s embedded in the page, inserting the widget HTML code into the DOM at that position. (It always assumes you’re embedding, which is why if you create a new widget in a head script or in the context of the window it will end up embedding itself in the root of the window.)

    But, you can still create the widget using a function (as long as it’s called from the embedded script) and then hold onto a reference to the widget for later. When you call .render() later the widget just re-renders itself wherever it happens to be.

    There are some pseudo-private methods on the TWTR object that you might try for fun, such as _getWidgetHtml() – which is called by .render() but you shouldn’t need to use those.

    I just wrote the following code, and it works well for me. Call this function from your embedded script (as shown), then call it again later with a new search parameter to re-render it.

    <div id="my_widget_region">
      <script src="http://widgets.twimg.com/j/2/widget.js"></script>
      <script>do_twitter_widget('"#winning" or "justin bieber"');</script>
    </div>
    
    function do_twitter_widget(search_query, title, subtitle) {
      if (!window.widgetRef) {
        window.widgetRef = new TWTR.Widget({
          version: 2,
          type: 'search',
          search: search_query,
          interval: 6000,
          title: title || 'Tweets related to',
          subject: subtitle || search_query,
          width: 'auto',
          height: 500,
          theme: {
            shell: {
              background: '#8EC1DA',
              color: '#FFFFFF'
            },
            tweets: {
              background: '#FFFFFF',
              color: '#444444',
              links: '#1985B5'
            }
          },
          features: {
            scrollbar: false,
            loop: true,
            live: true,
            hashtags: true,
            timestamp: true,
            avatars: true,
            behavior: 'default'
          },
          ready: function() {
            // when done rendering...
          }
        });
    
        window.widgetRef
          .render()
          .start();
      }
      else {
        if (search_query != window.old_twitter_search) {
          window.widgetRef
            .stop()
            .setSearch(search_query)
            .setTitle(title || 'Tweets related to')
            .setCaption(subtitle || search_query)
            .render()
            .start();
        }
      }
    
      window.old_twitter_search = search_query;
    
      return window.widgetRef;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add a row to my Model and have that option
I'm trying to allow users to upload a profile image on their user profile
I'm trying to add an option to the TinyMCE ContextMenu plugin and I have
I'm trying to add a div when an option is selected from the list.
So I'm trying to add UIImageViews programatically (in this case I don't have the
Im trying to add objects to an array by using push. I have a
I'm trying to add upload controls to the page. This HTML mark-up with JavaScript
I'm trying to get the javascript below to automatically update the input field (centimeters)
I'm trying to add an option for my Windows Froms application which will allow
I am trying to add the option fields on a row to the total

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.