can't cancel default dragover after animating
Hi,
I have a <ul> with <li>'s inside. When I drag something over an <li> it will animate. I then want to cancel the default dragover handler so that I can enable drop on this <li> (I am targeting Google Chrome only, so I only need to cancel the dragover event to enable dropping).
- $('li').bind("dragover", dragoverCallback);
- function dragoverCallback (event) {
- var target = $(event.target);
- target.unbind("dragover", dragoverCallback);
- target.animate({'left':'100px'}, {'complete': function() {
- target.bind("dragover", dragoverAnimationCallback);
- }});
- }
- function dragoverAnimationCallback (event) {
- var target = $(event.target);
- // if I comment out the following line, it will work, but then this callback function is getting hammered
- target.unbind("dragover", dragoverAnimationCallback);
- event.preventDefault();
- }
However, I see that after the animation, dropping is allowed for a split second, and then the default behavior (not allowing drop) happens again. I'm not sure why. If I comment out line 12, it will work, but then I'm not unregistered the callback, which seems bad.
Why is the default not being prevented?