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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:53:38+00:00 2026-06-04T00:53:38+00:00

I am working on a widget/gadget based website, where the user can have the

  • 0

I am working on a widget/gadget based website, where the user can have the same the same widget/gadget on the same page at the same time. For example, the following could be a widget/gadget:

<div class="widget widget_1">
    <div class="header widget_header_1">
        <input type="text" class="textbox_1"/><input type="button" class="button_1"/>
    </div>
    <div class="content widget_content_1"></div>
    <div class="footer widget_footer_1"></div>
</div>

I can then have many of these on screen at once, which is why I am using classes instead of id’s.

on document.ready, I run a function which generates default values for widget_content_1. The problem is that when another of these identical widget is added by the user, the default function resets all widget_content_1 widgets to the default value. How do I stop this from happening and how do I only apply default values to the newly added widget without affecting the others?

The code currently looks like this:

// on document ready:
function_default();

...

function function_default() {
    $('.widget_content_1').empty().append("default content here");
}

Anyone know how to resolve this issue?

  • 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-04T00:53:41+00:00Added an answer on June 4, 2026 at 12:53 am

    Using a position specific selector is a solution, but also error prone if the newest widget is not always in a specific position.

    I would simply add a flag, new to the newly created widget, in whatever place it is created:

    <div class="widget widget_1 new">
        ...
    </div>
    

    And then use this selector in jQuery:

    function function_default() {
        $('.widget.new').empty().append("default content here").removeClass('new');
    }
    

    If n number of new widgets have been created, this will also add the default content to all of them.

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

Sidebar

Related Questions

I'm working on a text-based UI widget library, and have decided it's high time
I have a Widget i am working on, that allows the user to have
I am working on a home screen widget. I hope this widget can support
I'm trying to get a color picker javascript widget working in a page with
I am working on a simple drawing widget in Qt (all of the following
I have a question about Javascript widgets. The widget I am working on simply
I am working on a form widget for users to enter a time of
Currently i am working on a plugin and widget based CMS. A widget is
I'm working on a javascript widget (with jQuery) that others can embed on their
I'm using the following widget to allow a user to input a date $this->widgetSchema['first_registration']

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.