I am using Jquery Ui’s draggable and the revert option.
Is there a way to detect whether the element is reverting?
$(function() {
$("#draggable").revert(function(){
alert('the div is reverting');
});
});
Ive seen
revert:function(){
alert("");
}
However it seems to set the revert position to where the mouse has been released.
Right now, the option i seem to have is to use mouseup.
It’s actually interesting that that works at all. I was unable to find any mention of it in the documentation. It appears that the function is called and if
trueis returned it will revert iffalsethen it will not revert. Since you have no return at all, it is treated asfalse.So, if you were using the revert option with
trueas the value (which means, always revert), then you can simply add a return statement to your function:If you were setting revert to
invalidhowever, I’m unsure how you could do this.And since it’s not documented, use at your own risk I guess.
EDIT: I looked into it a bit more and apparently an agument is passed to the function which is the droppable it was dropped on, and false if no droppable. So technically you could emulate
invalidlike this: