Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#7626 closed bug (notabug)

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.

Change History (6)

comment:1 Changed 8 years ago by Scott González

Resolution: invalid
Status: newclosed

We don't support cloning widgets.

comment:2 Changed 8 years ago by dustinboston

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.

comment:3 Changed 8 years ago by Scott González

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

comment:4 Changed 8 years ago by Scott González

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

comment:5 Changed 8 years ago by dustinboston

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");

comment:6 Changed 5 years ago by calahir

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");
Note: See TracTickets for help on using tickets.