【问题标题】:Set connectToSortable based on what it is hovering over根据悬停的内容设置 connectToSortable
【发布时间】:2014-02-21 14:53:39
【问题描述】:

我有一个可拖动的对象,但屏幕上有 N 个可排序的对象,实际上,它们是嵌套的。不太像无序列表的无序列表,但这是一个可靠的例子。

根据我悬停在可拖动对象上的内容,我想设置我希望附加到的相应可排序列表。我在想类似的东西:

$(_d).draggable({
    helper: "clone",
    drag: function(){
       //get position.
       //compare position with all container dimensions.
       //if match,  $(this).draggable("options", "connectToSortable", "selector-for-particular-sortable
    },
    stop: function(){},
});

/*dynamic, so i cant use connectToSortable on all of them.*/
$(_a).sortable();
$(_b).sortable();
$(_c).sortable();

我只是觉得在屏幕上拖动和扫描所有容器对象很耗时。我不确定是否有其他人做过类似的事情。

我的想法源于我正在关注的一个项目,同时也在关注:jQuery UI draggable element dropped into sortable

【问题讨论】:

    标签: jquery jquery-ui jquery-ui-sortable jquery-ui-draggable


    【解决方案1】:

    如果你可以分配一个类,或者知道一组代表一个可排序对象的类,你就可以将它们直接添加到 connectToSortable 对象中。

    查看示例:http://jsfiddle.net/4UR8X/

    $(item).draggable({helper:'clone', connecToSortable:'.containers'});
    

    【讨论】:

      猜你喜欢
      • 2013-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-17
      • 1970-01-01
      • 1970-01-01
      • 2018-03-31
      相关资源
      最近更新 更多