jQuery UI 拖动 - 正在使用哪个处理程序?

发布于 2024-09-18 05:40:22 字数 653 浏览 5 评论 0原文

我对拖放功能进行了以下设置:

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。

感谢您的所有回答!

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) {
        // tell 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我不会写诗 2024-09-25 05:40:22

我还没有机会测试这个,但是你可以使用 - 获取 id 吗?

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

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

$(ui.draggable).attr("id")
|煩躁 2024-09-25 05:40:22

不幸的是,这没有帮助。我需要知道正在使用 ui.draggable (或实际上:ui.helper)元素内的哪个处理程序。
伪代码:

//return the id of the handler currently used to move the element
$(":handler", ui.helper).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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文