RubaXa/Sortable — pull request #43 by Luismahou (2014-05-05 05:34:24+00:00)
Title: Cancel dnd

Hi there!

These changes are solving an edge case I'm experiencing using your **great** library.

In my case, I use Sortable to reorder a set of tiles which represent a shared model in the backend. Tiles can be reordered by a different user. When that happen, the change is notified via websockets, and the tiles are re-arranged.

The issue comes when tiles are modified by another user while the current user is trying to reorder one tile. For example, one user could delete the tile that is being dragged at the moment. To me the logical solution is to cancel the current Drag and Drop operation. Sadly, I haven't found a way to do it. This PR adds a **cancel** method that invalidates the current Drag and Drop operation. It doesn't do a **real** cancellation (like pressing the Escape key would do) because as far as I know there is no way to do it.

Before creating this PR I tried first to **destroy()** and then recreate sortable, but apparently, destroying sortable in the middle of a drag operation leaves the browser in an inconsistent state, preventing new drags from working.

Please let me know if you want me to do something else or if you think it could be solved in a better way.