Using jQuery UI, I'm dragging/dropping a div from one div to another.
The dropping event triggers:
The toggling occurs before the animation is complete. I need the toggling to occur AFTER the animation completes.
http://jsfiddle.net/dominornovus/3Hq3q/2/
I've unsuccessfully attempted use of an animated selector:
$(":animated").promise().done(function() {
//code here
}
How do I prevent the toggle occurring before the droppable animation.
Use the callback in animate()
:
$('.drop').droppable({
tolerance: 'intersect',
drop: function(event, ui) {
var drop_p = $(this).offset();
var drag_p = ui.draggable.offset();
var left_end = drop_p.left - drag_p.left + 1;
var top_end = drop_p.top - drag_p.top + 1;
ui.draggable.animate({
top: '+=' + top_end,
left: '+=' + left_end
}, function() { //callback
$(".somediv").toggle();
});
}
});