Skip to main content

Search and Top Navigation

#7626 closed bug (notabug)

Opened August 10, 2011 05:55PM UTC

Closed August 10, 2011 06:19PM UTC

Last modified December 10, 2014 09:37AM UTC

draggable("destroy") does not destroy deep cloned objects

Reported by: dustinboston Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.draggable Version: 1.8.15
Keywords: Cc:
Blocked by: Blocking:
Description
  • jQuery version's tested: 1.4.4-1.6.2
  • jQuery UI version tested: 1.8.14
  • Browser's tested: FF5, Chrome 13.0.78.112
  • Platform: Windows

How to reproduce

Go to the example at http://jsfiddle.net/Rb52z/13/

The second box is the cloned item. Items that have the .ui-draggable class are outlined in black. Click the destroy link to destroy the draggables.

Expected behavior

All outlines go away (draggable is destroyed for *all* elements)

Actual behavior

Only the original draggable is destroyed, the clone is not

The same thing happens with resizable.

Attachments (0)
Change History (6)

Changed August 10, 2011 06:19PM UTC by scottgonzalez comment:1

resolution: → invalid
status: newclosed

We don't support cloning widgets.

Changed August 10, 2011 07:10PM UTC by dustinboston comment:2

I think that needs to be specifically stated somewhere so people don't waste their time making repro cases and reporting bugs that are not going to be considered.

Changed August 10, 2011 07:19PM UTC by scottgonzalez comment:3

Do you have a suggestion for a location to put a note that people would see it?

Changed August 10, 2011 07:21PM UTC by scottgonzalez comment:4

Also, for reference, we do have a feature ticket for this, but I'm not sure if it will ever be worked on: #3803.

Changed August 10, 2011 11:24PM UTC by dustinboston comment:5

Yes, I think it would be really helpful to add a Frequently Asked Questions page like http://docs.jquery.com/Frequently_Asked_Questions to http://jqueryui.com/demos/ under the "For Developers" section. This could be useful for answering other questions of this nature.

Regarding the feature ticket, I don't know that cloning should be supported. I was originally trying to point out a potential bug in the destroy method on draggables (also applies to resizables) which excludes cloned elements. I've been through the code but I'm not quite sure why it doesn't destroy clones at this point.

As a workaround I simply copied all the code from the destroy method and used the selector for my cloned items to destroy them. But that's obviously undesirable:

$(".your-draggable")
	.enableSelection()
	.removeData("draggable")
	.unbind(".draggable")
	.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");

Changed December 10, 2014 09:37AM UTC by calahir comment:6

Thank you very much. This code spinnet works well. I think clone(true) have to handle this problem.

$(".your-draggable")
	.enableSelection()
	.removeData("draggable")
	.unbind(".draggable")
	.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");