Revert a jQuery draggable object back to its original container on out event of droppable

I revert when I'm not dropped

Drop me here

Hack Explanation

the method revert accept true / false ( in newest version also valid/invalid ) as parameters.

if we pass a parameter as function and we console.log() the event var we see that when the draggable move over a droppable it return an object otherwise it return false.

 
                
                     // so we check that event is not boolean false
                    return ( event !== false ) ? false : true;
                
                 
                     // OR simply
                    return !event;
                
                

now, when you return false the revert stop and the draggable holds on the droppable,

when you move it outside the droppable it return true and the draggable revert to it's original position.

The other part of the trick is to find and overwrite the original position of the draggable element.

and we do this by accessing the uiDraggable data() object and setting it to { left : 0, top : 0 }