Skip to main content

Search and Top Navigation

#5055 closed bug (duplicate)

Opened January 11, 2010 07:11PM UTC

Closed January 19, 2011 03:53PM UTC

Last modified January 19, 2011 03:53PM UTC

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:
Description

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.

Attachments (0)
Change History (4)

Changed January 13, 2010 12:25AM UTC by scottgonzalez comment:1

milestone: TBD1.8
priority: minormajor
summary: ui.sortable cancel sorting with a keypressSortable: cancel method does not work properly
type: enhancementbug

Changed October 27, 2010 09:45AM UTC by sactor comment:2

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

Changed January 19, 2011 03:53PM UTC by scottgonzalez comment:3

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();​

Changed January 19, 2011 03:53PM UTC by scottgonzalez comment:4

Duplicate of #5882.