jQuery: The Write Less, Do More JavaScript Library

Ticket #2063 (assigned enhancement)

Opened 7 months ago

Last modified 6 months ago

Droppable accept function improvement

Reported by: mnichols Assigned to: rworth (accepted)
Type: enhancement Priority: major
Milestone: 1.2.2 Component: ui
Version: 1.2.1 Keywords:
Cc: Needs: Review

Description

I am commonly needing to get the droppable element being targeted during an 'accept' callback to determine if the draggable signature is acceptable against the droppable element. There isn't an easy way to get the droppable instance during this callback, so I changed draggable and droppable to use 'call' while passing in the droppable instance to force 'this' to always be the droppable being targeted during the accept callback. Really, the 'ui' object should be getting passed in to this callback just like the other options to be consistent. Please see attached patches or consider changing the method signature of this callback ... the function callback seems to have been an afterthought.

Attachments

uidraggable121607.patch (1.2 kB) - added by mnichols 7 months ago.
Draggable using 'call' for accept callback
uidroppable121607.patch (2.2 kB) - added by mnichols 7 months ago.
Droppable invoking using 'call' on accept callback
uidroppable-pass.ui.to.accept.patch (2.4 kB) - added by mnichols 7 months ago.
Patch successfully passes ui to the accept function of droppable
droppable.accept.this.patch (0.7 kB) - added by m0n5t3r 6 months ago.
droppable accept hack

Change History

Changed 7 months ago by mnichols

Draggable using 'call' for accept callback

Changed 7 months ago by mnichols

Droppable invoking using 'call' on accept callback

Changed 7 months ago by mnichols

My draggable patch has a small error...it is passing the draggable instead of the draggable.element as other parts do. Really, the documentation is wrong when it says that the draggable is passed to the accept callback since in fact the draggable.element is being passed.

Changed 7 months ago by rworth

  • owner set to rworth
  • status changed from new to assigned

Changed 7 months ago by mnichols

Patch successfully passes ui to the accept function of droppable

Changed 7 months ago by mnichols

Due to the complete rewrite of droppables recently, the first two patches are stale. I have created a new patch that allows passing the 'ui' object from droppable into the accept function. This gives developer better options for determining if an draggable should be accepted based on criteria found in the target droppable.

Please see attached ' uidroppable-pass.ui.to.accept.patch ' and disregard the previous patches....

Mike

Changed 7 months ago by mnichols

I submitted #2122 that has this patch and a fix to the most recent trunk. I'd recommend disregarding this patch to get the fix.

Mike

Changed 6 months ago by m0n5t3r

droppable accept hack

Changed 6 months ago by m0n5t3r

I think the above patch is a more elegant approach to passing the ui object as this to the accept function

Changed 6 months ago by mnichols

does this work on the rewrite that was done on the trunk?

Changed 6 months ago by m0n5t3r

it's made against r4501, should apply cleanly to current trunk (the changes that have occurred since then are fn API changes, the ui part is unchanged)

Changed 6 months ago by mnichols

If I understand your patch, it seems your patch is passing the droppable (not ui) to be this . The patch I submitted in #2122 passes the ui object as an arg the same as the other method calls. This is more intuitive I think than requiring the dev to back into the ui object thru this.

Note: See TracTickets for help on using tickets.