jQuery UI + Droppable Drop Event
My Droppable 'Drop' Event wouldn't fire. Pooh.
I had an image in my drop area div.I removed it and it now fires the event. Yippee.All other events fired as you'd expect, so I think this is a bug.Moral of this woeful little tale: Keep your images in the background of your div, or get hacking.
2 comments
Feb 26, 2011
Matt said...
I just ran into this too... still trying to figure out how to get around it. Glad to know that someone else has wasted time on the issue as well.
Feb 26, 2011
Matt said...
Figured it out... Key is the 'tolerance' qualifier when defining the droppable object that is an image:In HAML from a Rails app:
= image_tag "trashbin_empty.png", 'data-event-url' => url_for_event(:drop), :id => "trashbin"
:javascript
$(function() {
$("#trashbin").droppable({
tolerance: "pointer",
drop: function(event, ui) {
$.ajax({url: $("#trashbin").attr("data-event-url") + "&id=" + ui.draggable.attr("data-id")});
}
});
});