简体   繁体   English

拖动悬停时 Jquery 可排序

[英]Jquery sortable while dragging on hover

I'm using Jquery's sortable plugin, my question is as follows:我正在使用 Jquery 的 sortable 插件,我的问题如下:

When i'm dragging an element, once I hover a specified element with the one I am dragging, I want a function to be initiated.当我拖动一个元素时,一旦我将一个指定的元素悬停在我正在拖动的元素上,我想要启动一个函数。 Remember, not when i hover the element with my mouse, but with the element I am dragging.请记住,不是当我用鼠标悬停元素时,而是当我拖动元素时。

Thanks a lot for any help I get with this issue :)非常感谢我在这个问题上得到的任何帮助:)

Bind the event after a sortstart is fired触发sortstart后绑定事件

$( ".selector" ).sortable({
   start: function() { 
      $('#elementThatWillBeHoveredOver').hover(hoverStart, hoverEnd);
   }
   stop: function() { $('#elementThatWillBeHoveredOver').off('hover') }
});

I had the same problem as you.我和你有同样的问题。 I tried several alternatives one with the method "Droppable", there is a jQuery plugin Droppable.我尝试了几种使用“Droppable”方法的替代方法,有一个 jQuery 插件 Droppable。

https://api.jqueryui.com/droppable/ https://api.jqueryui.com/droppable/

$( ".Permissoes > div" ).droppable({
    over: function(event, ui){
        console.log('fn:over',event,ui);
    },
    out: function(event, ui){
        console.log('fn:out',event,ui);
    },
    drop: function(event, ui){
        console.log('fn:drop',event,ui);
    }
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM