Opened 10 years ago

Last modified 4 years ago

#4303 open bug

sortable: receive: ui.item references the source element

Reported by: Marc Diethelm Owned by:
Priority: major Milestone: 2.0.0
Component: ui.sortable Version: 1.7
Keywords: haspatch Cc:
Blocked by: Blocking:

Description

I used to be able to manipulate/replace a dropped element (dragged from a draggable with helper: "clone") in the sortable's receive handler using ui.item. But now ui.item references the source element.

Attachments (2)

sortable.receive-callback.ui.html (2.0 KB) - added by Marc Diethelm 10 years ago.
Testcase
sortable-item-sender.patch (1.3 KB) - added by asannes 9 years ago.
Make sure item is the item being added and sender is still the sender

Download all attachments as: .zip

Change History (20)

Changed 10 years ago by Marc Diethelm

Testcase

comment:1 Changed 10 years ago by Marc Diethelm

forgot to set the component...

comment:2 Changed 10 years ago by rdworth

Component: ui.coreui.sortable

comment:3 Changed 10 years ago by rdworth

Resolution: invalid
Status: newclosed

This is as designed. The property you want is ui.helper.

comment:4 Changed 10 years ago by codeofficer

Altering ui.helper seems to have no effect for me. And I'm not sure I understand why ui.item and ui.sender both refer to the same element now. ui.item used to refer to the dropped element.

Something changed in 1.7, my old code was working fine in 1.6. Its not clear to me what the workaround should be to alter the contents of a dropped element in a sortable's receive callback.

comment:5 Changed 10 years ago by rdworth

Resolution: invalid
Status: closedreopened

comment:6 Changed 10 years ago by rdworth

Milestone: TBD1.8
Owner: set to rdworth
Status: reopenedassigned

Changed 9 years ago by asannes

Attachment: sortable-item-sender.patch added

Make sure item is the item being added and sender is still the sender

comment:7 Changed 9 years ago by asannes

This makes it work for me, no guarantees tough. The patch is against 1.7.2 ..

comment:8 Changed 9 years ago by rubyjedi

Thank you! sortable-item-sender.patch is exactly what I need. Similar use case - I alter ui.item with html() or replaceWith() in the receive handler.

Without the patch, there's no easy way to alter the item before it's inserted to the Sortable, as ui.helper is a throw-away clone, and ui.sender (in my use case) is merely a thumbnail image. Unpatched seems to always clone ui.sender.

comment:9 Changed 8 years ago by aheywood

Thanks for the patch, I had to use this on v1.8 to get it working, otherwise there is no easy way to manipulate the dropped item.

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

Priority: criticalmajor

comment:11 in reply to:  7 Changed 8 years ago by tobymackenzie

Replying to asannes:

This makes it work for me, no guarantees tough. The patch is against 1.7.2

..

Where can I find this patch?

comment:12 Changed 7 years ago by micha-f

I also applied this patch in order to be able to modify the dropped element in the sortreceive callback. Works with 1.8.18.

comment:13 Changed 6 years ago by Scott González

Milestone: 1.9.02.0.0

comment:14 Changed 6 years ago by mikesherov

Owner: rdworth deleted
Status: assignedopen

This is still valid. And the attached patch works. The lines have moved, but they're here now:

https://github.com/jquery/jquery-ui/blob/bae06d2b1ef6bbc946dce9fae91f68cc41abccda/ui/jquery.ui.sortable.js#L1018 https://github.com/jquery/jquery-ui/blob/bae06d2b1ef6bbc946dce9fae91f68cc41abccda/ui/jquery.ui.sortable.js#L1090

I'm taking this off of Richard as he hasn't touched this ticket in 4 years.

comment:15 Changed 6 years ago by mikesherov

Keywords: haspatch added

comment:16 Changed 6 years ago by tj.vantoll

The following test case shows this http://jsfiddle.net/tj_vantoll/5fJ6q/.

comment:17 Changed 6 years ago by tj.vantoll

#4253 is a duplicate of this ticket.

comment:18 Changed 4 years ago by tj.vantoll

#11227 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.