开发者

jQuery UI Dragging - which handler is being used?

开发者 https://www.devze.com 2023-01-15 07:20 出处:网络
I got the following setup for dragdrop functionality: const listDragOptions = { handle: \".camera, .texter\", // dragged by either camera or edit icon

I got the following setup for dragdrop functionality:

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) {
        // 开发者_如何学JAVAtell me which handle is being used!
    }
}

Basically I need to know which of the two handles ".camera, .texter" the user has clicked to achieve ddragging functionality. This seems tricky. I can't find anything in the API, so I'm really willing to accept any dirty hack.

Thanks for all answers!


I've not had chance to test this, but are you able to grab the id using -

$(ui.draggable).attr("id")


Unfortunately, this doesn't help. I need to know which handler inside the ui.draggable (or actually: ui.helper) element is being used. Pseudo-Code:

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

However I have solved the problem by just adding another draggable element. It's too bad though.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号