【问题标题】:Add droppable element with Mootools' drag&drop使用 Mootools 的拖放添加可放置元素
【发布时间】:2012-07-23 14:54:31
【问题描述】:

这是我的问题,我正在使用 mootools 的 Drag&Drop 功能,它工作得很好,但我找不到动态添加新可放置元素的方法,因为可放置元素是在可拖动元素时定义的。 它们是一种 makedraggable 方法,您可以使用它来添加可拖动元素,但它没有与 droppables 等效的方法。

使用 jQuery,您可以在一侧设置可拖动元素,在另一侧设置可放置元素,因此您几乎可以做任何您想做的事情。

你知道解决我问题的方法吗?

【问题讨论】:

    标签: drag-and-drop mootools


    【解决方案1】:

    理论上,您应该能够将元素推送到instance.droppables 集合。

    var foo = new Drag.Move({
        droppables: document.getElements('div.dropHere'),
        ...
    });
    
    
    foo.droppables.push(document.id('newDropHere'));
    // or... 
    foo.droppables.include(element); // etc. all array/Elements methods. 
    

    阅读https://github.com/mootools/mootools-more/blob/master/Source/Drag/Drag.Move.js

    如果您需要实际帮助,请在 tinker.io 或 jsfiddle.net 上构建一个示例。如果记忆有用,这已经被问过here,除了添加到Collection之外,还必须做一些额外的工作来解析可能的droppables。

    【讨论】:

      猜你喜欢
      • 2018-09-29
      • 1970-01-01
      • 1970-01-01
      • 2012-02-05
      • 1970-01-01
      • 1970-01-01
      • 2018-08-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多