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

  • Home
  • SEARCH
  • 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 8783311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:47:59+00:00 2026-06-13T20:47:59+00:00

I have 3 of the same widgets on my screen, widgets as in 3

  • 0

I have 3 of the same widgets on my screen, widgets as in 3 div tags with content which the user chooses to have on his/her screen, which s/he can move and arrange on the screen. A bit like what iGoogle did. So basically, they can have 0 or more of the same widgets on the screen.

I got this working by using classes in the html instead of ids.

<div class="widget_1">
    <div class="widget_header_1"></div>
    <div class="widget_sub_header_1"></div>
    <div class="widget_content_1"></div>
    <div class="widget_footer_1"></div>
<div>

So if I have 2 of these widgets, the users screen will have 2 widgets with the class widget_1, i.e. the above html will be in the html source twice.

Anyway, I have a button in the sub_header of the widgets which adds data to the content section of the widget, i.e.

$('.my_button').live('click',function() {
    get_data( $(this) );
});

That works fine, as in, if I click on the button in the first widget_1, only it’s content will change, if I click on the button in the second widget_1, only it’s content will change and it will not effect the other widget_1‘s.

To do that I am using:

$(this).closest('.widget_1').find('.widget_content_1').empty().append( some_data_here );

My question is, I want to prepend a loading image into the content when a button is clicked in the sub_header of a widget, so I tried:

$(this).closest('.widget_1').find('.widget_content_1').prepend( "<img class='imgLoading' src='/img/loading_white_32.gif'></img>" );

This works in that it only displays a loading image in the widget in which the button was clicked, but it displays 2 images in the clicked widget_1 if I have 2 widget_1‘s on the screen, and it will display 5 images in the clicked widget_1 if I have 5 widget_1‘s on the screen.

Why is that happening?

It should be displaying just 1 loading image in the clicked widget_1 no matter how many widget_1‘s are on the screen.

  • 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-13T20:48:00+00:00Added an answer on June 13, 2026 at 8:48 pm

    It looks like the code:

    $('.my_button').live('click',function() {
        get_data( $(this) );
    });
    

    Runs once for each widget you create. This is unnecessary, and actually counter-productive, because a single call to live() installs a delegated handler that will “see” the click events bubbling from all the elements that match .my_button, whichever widget they reside in.

    You have to find a way for that code to only run once (possibly in your widget’s common initialization routine if it has one).

    In passing, note that live() is deprecated in favor of on() since jQuery 1.7. The code above would become:

    $(document).on("click", ".my_button", function() {
        get_data( $(this) );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can we have same delegate for two events ? which have same number of
I have dynamically generated div tags which looks something like this: <div class=widget widget_1>
I have a scenario where combobox can have same string values. for exa combo
I want to display some div's in a wrap. The div have same class
I am working on a widget/gadget based website, where the user can have the
Hopefully this will make sense. I have a page where an user can create
I have a QTabBar, and all tabs are supposed to have the same widget
Is it possible to have same table name on different schema with different data
Html text box should have same font size for both upper and lower case
Is it possible to have same hashcode for different strings using java's hashcode function?or

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.