Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#5055 closed bug (duplicate)

Sortable: cancel method does not work properly

Reported by: jessicah Owned by:
Priority: major Milestone: 1.9.0
Component: ui.sortable Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:


Have been unable to find a way to cancel sorting with a keypress.

E.g. I start sorting, then want to press Escape to cancel and revert to previous state.

My attempt inside the sort callback was to attach to the keydown handler and call $("#sortable").sortable('cancel'), but the state of the sortable was left inconsistent. The placeholder element didn't disappear, and the dragged item got left as is on the page.

In fact, the placeholder seemed to become part of the list, and the "orphaned" item was still draggable. Dragging the same or other item added a new placeholder.

Change History (4)

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

Milestone: TBD1.8
Priority: minormajor
Summary: ui.sortable cancel sorting with a keypressSortable: cancel method does not work properly
Type: enhancementbug

comment:2 Changed 12 years ago by sactor

Having the same problem in 1.8.5. Hope it'll get fixed in 1.9.

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

Resolution: duplicate
Status: newclosed

Closing as a duplicate of #5882 which I just landed a fix for. After this fix, the following code seems to works as expected:

$( document ).keydown(function( event ) {
  if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
    $( "#sortable" ).sortable( "cancel" );

$( "#sortable" ).sortable();​

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

Duplicate of #5882.

Note: See TracTickets for help on using tickets.