I have a problem with jQuqeryUI.
I would like to run some code whenever an element is dragged and dropped on an invalid target.
As far as I can see, there is no predefined event for this, but I have thought about combining information from following events: over, out, remove and stop, to achieve this. However that might sound like it’s going to be a mess, is there a cleaner way yo do it?
I have a problem with jQuqeryUI. I would like to run some code whenever
Share
You can pass a method to the
revertoption as well, for example if we take the example demo like this:Then on your draggable you can calculate whether to revert, like this:
You can give it a try here, the
droppedparameter passed in is the element it was dropped on that’s a.droppable(), it’s justfalseif it landed anywhere else.Or if you’re using the
acceptoption you may want to calculate off that, like this:This uses the accept selector and uses
.is()to see if the droppable matches.You can view a demo of that here.