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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:02:58+00:00 2026-05-27T12:02:58+00:00

I have this code, but when I clone an element, then the action is

  • 0

I have this code, but when I clone an element, then the action is also cloned. What i want is just individual actions for each element.You can see the problem in demo

<script type="text/javascript">
$(document).ready(function() {
    $('.edit').editable('http://save.php', {
        indicator : 'Saving...',
        submit    : 'OK',
        cancel : 'Cancelar',
    }); 
});


$(document).ready(function () {
    $('#btnAdd').live('click', function(){
        var num = $('.clonedInput').length;
        var newNum = new Number(num + 1);

        var newElem = $('#input' + num).clone(true).prop('id', 'input' + newNum);

        newElem.children(':text').prop('name', "myformdata[job][]").prop('job', 'job').val('');

        $('#input' + num).after(newElem);
        $('#btnDel').prop('disabled', '');

        if (newNum == 4) $('#btnAdd').prop('disabled', 'disabled');

    });

    $('#btnDel').live('click', function(){
        var num = $('.clonedInput').length;

        $('#input' + num).remove();
        $('#btnAdd').prop('disabled', '');

        if (num - 1 == 1) $('#btnDel').prop('disabled', 'disabled');

    });

    $('#btnDel').prop('disabled', 'disabled');

});
</script>

    <div class="clonedInput" id="input1">
        <span style="float: left;">job</span>
        <div class="edit" id="job="myformdata[job][]">Job</div>
    </div>

    <div id="copy">
        <input class="format" type="button" id="btnAdd" value="Ad" />
        <input class="format" type="button" id="btnDel" value="Re" />
    </div>

demo

  • 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-27T12:02:59+00:00Added an answer on May 27, 2026 at 12:02 pm

    RightSaid is correct, just use .clone() w/o any parameters and it will not clone the handlers/data.

    As for your code, I think this is what you were going for: http://jsbin.com/unebex/11/

    You have to set the new elements to ‘editable’ as you create them. There is no need to use .live() on those buttons since you are not creating new instances of those buttons.

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

Sidebar

Related Questions

I have a greasemonkey user script with this single line of code... window.close(); but
Hey I have this code but it doesn't work because it is expecting a
I have this code that works in a unit test but doesn't work when
I have this code so far which perfectly but relies on there being a
I have this code to draw an ellipse in the screen but I don't
I have this code, but I have a problem. When I update but do
I have this code, but i cant make it work: images = Image.find_by_sql('PREPARE stmt
I have this code which gets WP posts, but it gets all the posts
I have this code to update users data, but I can't write the for
I have this code, which works fine, but I would like to be able

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.