Pascal
Pascal

Reputation: 12855

How does jquery draggable revert and droppable.drop function play together

I have seen multiple different behaviors in my code (due to a bug maybe) how the draggable revert function works together with the droppable drop event.

So I need clarification.

My expectation is that the revert function is called FIRST before the drop event.

Depending on the value of revert() function:

return true // does not fire the drop event because the drop is reverted...

return false // does fire the drop event

Can someone pro please tell me wether my assumption is right, because my code is not behaving like that.

The code is too much to post here, sorry can`t post.

Upvotes: 0

Views: 262

Answers (1)

blgt
blgt

Reputation: 8205

The two are unrelated.

When you mouseup your draggable over a droppable, the first thing that's called is the droppable's accept option (if it's a function, or just matched if a selector). Based on this you'll get two outcomes:

  • If accept matches/returns true, then the drop event is triggered on the droppable; also, the revert function (if it's a function) is called on the draggable with the droppable's jQuery object as its first parameter. AFAIK these are generic jQuery custom events and aren't guaranteed to be in any specific order; though I believe the drop event handler will usually run first

  • If accept doesn't match/returns false, the revert function is called without any parameters

Upvotes: 0

Related Questions