Search code examples
jqueryjquery-uidroppablejquery-ui-droppable

jQuery UI Droppable not accepted event


UI droppable for a project, I would like to detect the opposite to the accepted event.

I mean that if i drag and drop a not accepted container do some action, so far I haven't found any way to detect it.


Solution

  • Found out that using the revert option for the draggable event can solve it.

    $("selector").draggable({
        revert : function(droppableContainer) {
                if(droppableContainer) {
                    // drop is valid
                }else {
                    // drop is invalid
                }
                return(!droppableContainer) //returns the draggable to its original position
            }
       });