DannyG DannyG -4 years ago 126
jQuery Question

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.

Answer Source

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
        }
   });
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download