【问题标题】:jQuery UI Dragging - which handler is being used?jQuery UI 拖动 - 正在使用哪个处理程序?
【发布时间】:2011-04-09 04:51:00
【问题描述】:

我为拖放功能设置了以下设置:

const listDragOptions = {
    handle: ".camera, .texter", // dragged by either camera or edit icon
    //revert: true, // so dragged elements fall back to their original position,
    revertDuration: 200, // the element goes back instantly, no need for effects on this one
    snap: true, // snap to table cell edges
    helper: "clone", // create a cloned element instead of moving the original one
    drag: function(event, ui) {
        // tell me which handle is being used!
    }
}

基本上我需要知道用户点击了两个句柄“.camera,.texter”中的哪一个来实现拖拽功能。 这似乎很棘手。我在 API 中找不到任何东西,所以我真的很愿意接受任何肮脏的 hack。

感谢所有回答!

【问题讨论】:

    标签: jquery user-interface drag-and-drop handle


    【解决方案1】:

    我还没有机会对此进行测试,但是您可以使用 -

    来获取 id
    $(ui.draggable).attr("id")
    

    【讨论】:

      【解决方案2】:

      不幸的是,这无济于事。我需要知道ui.draggable(或实际上:ui.helper)元素中的哪个处理程序正在被使用。 伪代码:

      //return the id of the handler currently used to move the element
      $(":handler", ui.helper).attr("id"); 
      

      但是我通过添加另一个可拖动元素解决了这个问题。不过也太可惜了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-08-02
        • 2015-10-20
        • 2011-03-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多