Having a problem with jQuery UI draggable / droppable.
Basically, when i drop the item, it doesn't drop at the point where the cursor is. It seems to drop at maybe the centre of the element I'm dragging, but certainly not the cursor.
Here is the code:
$('.project, .milestone, .todoList, .todoListItem').draggable({
revert:'invalid'
});
$('.dayWrapper').droppable({
tolerance:'pointer',
drop: function(event, ui){
var sch_item = ui.draggable.attr('id');
var sch开发者_JAVA技巧_person = $(this).parent().attr('id');
var sch_date = $(this).attr('id');
addToSchedule(sch_item, sch_person, sch_date)
}
});
Thanks in advance
You must be omitting some part of your setup. Using essentially what you've provided, I can make an example that drops the item exactly where I let go of it. You seem to be suggesting that after the drop, it "snaps" somewhere else? As far as I know, unless you have code added to your drop function to do that, it just doesn't do anything.
See here for a simple example taken straight from the jQuery UI examples.
Pretty sure you're looking for the same answer suggested here: JQuery UI : Drop long element at the cursor location instead of the middle of the element
Basically use 'tolerance'.
精彩评论