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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:52:14+00:00 2026-05-30T14:52:14+00:00

I am experiencing a wierd behaviour with jquery-ui and jquery .clone() , remove(). I

  • 0

I am experiencing a wierd behaviour with jquery-ui and jquery .clone() , remove().
I am using jquery 1.7 and jquery-ui 1.8.16.
The problem is when i remove an element from a deep cloned element using remove() function , the remove affects the cloned element AND the corresponding element in the document by removing the draggable properties from the element in the DOM. I’m not sure if i’m doing anything wrong but it seems to me like either my misunderstanding of how clone(true,true) works or a bug in jquery-ui.

consider the following

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js" type="text/javascript"></script>
  <script type="text/javascript">
  $(document).ready(function() {
    $('#testp').draggable();
    //the following line causes the draggable classes to be removed from the document
    //as well as the cloned object ,the expected behaviour is that that #testp will be 
    //removed only from the clone...
          var test = $("#test")
           .clone(true,true)
           .find('#testp')
           .remove()
           .end(); //some more manipulation here
        });
  </script>
</head>
<body>
  <div id="test">
    <p id="testp">some text</p>
  </div>
</body>
    </html>

UPDATE:
It seems that .clone(true,true) still keeps some data shared among the clone and the original.
Even with changing the ids/applying .draggable() with a class selector and not removing any element from the dom, dragging the clone will move the original and not effect the clone(as one would think). other handlers like click etc ,are cloned correctly

After seeing some posts about issues cloned divs with (true,true) and draggable plugin, i’ve decided to refrain from cloned divs copying etc and just use detach() and reattach as a workaround.

Note to others who tried clone(true,true) to clone divs with draggable() plugin applied:
if you clone(true,true) some data will be copied to the clone and by applying draggable() to it you’ll be dragging the original, and i guess that’s not what you intened to do.
instead do a shallow .clone() and then bind draggable() to the clone.

  • 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-30T14:52:15+00:00Added an answer on May 30, 2026 at 2:52 pm

    Try separate statements:

    var test = $("#test");
    test.clone(true,true).appendTo("whatever").find('#testp').remove();
    

    PS: clone() and remove() are in jQuery core. Presence of jQuery UI should not affect them but by all means try without UI installed.

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

Sidebar

Related Questions

Experiencing jquery in rails through .js.erb templates; but completely puzzled by a simple problem
I'm experiencing this weird problem reading data from a table called nodes. Any select
i am experiencing some weird behaviour here. i am using the following code to
I'm experiencing some weird behaviour when using a ASP.NET LinkButton with a OnClientClick-property. ASPX
I'm experiencing this weird problem which my scrollbar jumps by itself to somewhere that
I'm currently working with jQuery 1.4.2 and jQuery UI 1.8.2. I'm experiencing some weird
Our team has been experiencing a recurring problem with velocity templates. Upon rendering, some
I am experiencing some weird encoding behaviour in my ASP.NET MVC project. In my
I'm experiencing a weird scrollbar issue. I'm building a page that uses jQuery and
I'm experiencing a weird problem with a SQL login. When I connect to the

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.