jquerydraggablejquery-ui-draggabledroppablejquery-ui-droppable

jQuery draggable revert : function() can't return "invalid"


So I want a piece of code executed when a draggable is reverted because it wasn't dropped on a droppable. Unfortunately return "invalid"; doens't seem to work, revert is acting like revert:true; Any suggestions how I can solve this?

revert: function () {
            //do some extra stuff...
            return 'invalid';
            }

Solution

  • hemant is right insofar that revertis not an event, it is an option, but its accepted values are not valid/invalid but true/false.

    See the jquery-ui-draggable manual which states:

    If set to true, the element will return to its start position when dragging stops. Possible string values: 'valid', 'invalid'. If set to invalid, revert will only occur if the draggable has not been dropped on a droppable. For valid, it's the other way around.