【问题标题】:Sortable over event get current droppable可排序事件获取当前可丢弃
【发布时间】:2012-07-30 16:47:06
【问题描述】:

使用over事件时,如何获取当前的droppable?对于当前的 droppable,我的意思是容器暂时悬停在上面。

这是我的代码让事情变得清晰:

$('#widgets-available, #sidebar-drop, #content-drop, #footer-drop').sortable({
    start: function(event, ui) {
        item = ui.item;
        newList = oldList = ui.item.parent().parent();
    },
    over: function(event, ui) {          
        //Get Current droppable??
    }
}).disableSelection();

});

【问题讨论】:

  • 您找到解决方案了吗?

标签: jquery jquery-ui jquery-ui-sortable jquery-ui-droppable


【解决方案1】:

在类似下面的事件中使用“this”

over: function(event, ui) {          
        $(this).find('.numdrag').size(); // give the count of elements with class .numdrag in the drop area 
    }

【讨论】:

    【解决方案2】:

    ...或者您可以直接使用事件中的属性而不是进行查找:

       over: function(event) { 
          var myDroppable = event.target; //this is element where it's being dropped 
          var mySortable = event.toElement; //this is the "handle" element that fired the sort event in the first place.
    }
    

    希望这可行

    【讨论】:

      猜你喜欢
      • 2023-03-11
      • 1970-01-01
      • 2012-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多