Jquery ui拖放drop drop drop“drop”事件

时间:2022-12-04 18:59:49

When I make a div droppable and try to set a drop event function it doesn't fire:

当我创建一个div droppable并尝试设置drop事件时它不会触发:

$('.item').draggable({

});

$('.destination').droppable({
   drop: function(event, ui){
     console.log('hiii');
   }
});

It fires when I drop it outside- to the right of the $('.destination') div, but not if I drop it inside the '.destination' div. See the full JS fiddle: http://jsfiddle.net/dylanjha/8TFMS/5/

当我将它放到$('。destination')div的右边时,它会触发,但如果我将它放在'.destination'div中,则不会触发它。看到完整的JS小提琴:http://jsfiddle.net/dylanjha/8TFMS/5/

1 个解决方案

#1


6  

For some reason, setting the margin:0 auto on the .item class causes this to not function properly. Removing it fixes the issue.

出于某种原因,在.item类上设置margin:0 auto会导致此操作无法正常运行。删除它可以解决问题。

jsFiddle example

#1


6  

For some reason, setting the margin:0 auto on the .item class causes this to not function properly. Removing it fixes the issue.

出于某种原因,在.item类上设置margin:0 auto会导致此操作无法正常运行。删除它可以解决问题。

jsFiddle example