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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:08:19+00:00 2026-06-11T20:08:19+00:00

Inspired by this answer here I am cloning a set of elements with jquery

  • 0

Inspired by this answer here I am cloning a set of elements with jquery and renaming the id’s accordingly in a .find .each loop to keep them unique.

like this:

newElement.find(':input').each(function() {
    var name = $(this).attr('name').replace('-' + 0 + '-','-' + total + '-');
    var id = 'id_' + name;
    $(this).attr({'name': name, 'id': id}).val('').removeAttr('checked');
});

So far so good, my goal is to check a checkbox in there as well that the form was originally cloned.

1) I have two ways to achieve this, I set the checkbox within the selector before renaming of the id’s take place.

$newElement  ??? -->  $('#id_deals-0-is_form_cloned_by_ajax').prop('checked', true);

2) Or I wait until the id’s have been renamed and have been made unique:

$('#id_deals-' + total + '-is_form_cloned_by_ajax').prop('checked', true);

The problem with the second approach is that the .find . each is an asynchronous approach and the renaming might have not taken place by the time I try to look for that checkbox’s id to set it.

Hence I thought approach one is safer, but I have no idea how to check for an ID within a selector only.

May anyone point me to the right direction please?

  • 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-11T20:08:20+00:00Added an answer on June 11, 2026 at 8:08 pm
    $newElement.find(':input').each(function() {
        var name = $(this).attr('name').replace('-' + 0 + '-','-' + total + '-');
        var id = 'id_' + name;
        $(this).attr({'name': name, 'id': id}).val('').removeAttr('checked');
    });
    
    // Find an element within $newElement
    $newElement.find('#id_deals-' + total + '-is_form_cloned_by_ajax').attr('checked', true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is inspired from the accepted answer here . Why does the following
Inspired by the encoding scheme of the answer to this question , I implemented
Inspired by this discussion , after some googling I wasn't able to find an
UPDATE: Here's my solution (inspired by accepted answer): function log(msg, values) { if(config.log ==
Inspired by this answer .. Can you guys point me to something similar--something that
Inspired by this answer about dynamic cast to void* : ... bool eqdc(B* b1,
inspired by this answer I'm trying to map a property on a model class
This question was inspired by this answer to another question, indicating that you can
Inspired by the top answer on this page I wrote a python program to
This question was inspired by this answer . I've always been of the philosophy

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.