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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:28:22+00:00 2026-06-16T03:28:22+00:00

Have a look at this example: http://jsfiddle.net/9NXHq/15/ It starts with one button defined via

  • 0

Have a look at this example: http://jsfiddle.net/9NXHq/15/

It starts with one button defined via HTML. I then clone that button using jQuery, change the text, and add it after the original button. Notice how the new button’s display is all messed up? But when you click the button, which causes the icon to be changed, it cleans itself up! What’s the proper way to clone elements which have already been jQueried?

For instance, imagine a list of data and an “Add” button. Clicking add clones an entire row of data (from a hidden template row, for example) which includes jQueried elements such as buttons, auto-completes, etc. How should the elements in this new row be “reconstituted” to ensure that they work properly?

HTML

<a id="btn">This is a button.</a>​

CSS

/* Standard jQuery UI (1.8.16 in this case). */

JavaScript

/* Standard jQuery (1.7.1 in this case). */

var btn = $("a#btn");
var btn2 = null;

btn.button({ icons: { primary: "ui-icon-plus" } });
btn.click(function ()
{    
    $(this).button({ label: "Clicked!", icons: { primary: "ui-icon-check" } });
});

btn2 = btn.clone();
btn2.click(function ()
{    
    $(this).button({ label: "Clicked! (2)", icons: { primary: "ui-icon-check" } });
});                   
btn2.text(btn2.text() + " (2)");
btn2.insertAfter(btn);

//Need to re-constitue btn2 as a button.
btn2.button();
  • 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-16T03:28:23+00:00Added an answer on June 16, 2026 at 3:28 am

    I remember trying to do this myself. This was the solution I settled with.

    // Get source buttons options.. for icons and stuff. 
    var btn_options = btn.button('option');
    
    // Clone the button, change the ID, and re-init the button. 
    var btn2 = btn
      .clone()
      .attr("id", "btn2")
      .button(btn_options);
    

    I tried .clone(true) but it ends up with all the binded events of the previous one. .button() simply does too much thing to just be able to .clone it, I found it easier to just copy the settings and reinit it.

    This is the fiddle: http://jsfiddle.net/9NXHq/23/

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

Sidebar

Related Questions

Have a look at this jsfiddle: http://jsfiddle.net/Dh96F/1/ The Expand button will animate the widening
Please take a look at this example. http://jsfiddle.net/LdeWK/2/ I want to know how to
Please take a look at this fiddle: http://jsfiddle.net/d3uc9/4/ I have a problem with this,
See this code example: http://jsfiddle.net/Z2BMK/ Chrome/IE8 look like this Firefox looks like this My
please run this jsfiddle as an example. http://jsfiddle.net/AFzqt/11/ in my example, i have a
I have tried this example http://www.bennadel.com/blog/1056-ColdFusion-CFPOP-My-First-Look.htm , but it retrieve emails from POP server.
Currently, I have URLs that look like this: http://www.example.com/user/create http://www.example.com/user/edit/1 But now, I have
I have a web application which uses URLs that look like this: http://library.example.com/Register.aspx?query=academic&key=586c70bb-5683-419c-aae9-e596af9ab66a (The
I have a list with CSS and HTML at http://jsfiddle.net/RyYem/2/ Problem Now listen very
http://jsfiddle.net/KKL5G/ Please take a look at the above html and css for the buttons.

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.