drag event for jquery-ui-sortable

Imran Naqvi picture Imran Naqvi · Nov 16, 2011 · Viewed 20.1k times · Source

How to listen to drag event when a jquery-ui-sortable is being dragged?

By hit-n-trial strategy, I've tried drag event from jquery-ui-draggable but it's not working.

$('.widget_container').sortable({
    drag: function(event, ui) { console.log('drag'); }
});

Answer

v42 picture v42 · Nov 16, 2011

Use sort event for this purpose:

$(".sortable").sortable({
    sort: function(e) {
      console.log('X:' + e.screenX, 'Y:' + e.screenY);
    }
});

http://jsbin.com/kegeb