jQuery UI 拖放 - 如何在拖动开始时隐藏原始容器?

标签 jquery user-interface drag-and-drop show-hide jquery-ui-draggable

我正在构建一个弹出图像库,用户可以将图像从弹出 div 拖放到页面上的其他位置。

弹出画廊是一个覆盖 div(使用 css),因此没有 iframe 或类似的东西。

我已经使用 JQUERY UI 成功实现了拖放,但我想要的是 -

Whenever a user drags an image out of the gallery popup div, the popup div should hide/fadeout and the image can be dropped elsewhere. But the problem is, as soon as I hide the gallery popup div (originating container), my helper clone also disappears. (however the drop can still be made, but I lose the visual feedback)

我尝试将图库 div 的位置移动到 -999,-999(不隐藏它),但即使这样也会隐藏我的视觉反馈克隆(助手)

请有人帮我找到解决方案。

谢谢

最佳答案

您应该能够使用draggable 的appendTo 选项来完成此操作。默认情况下,助手会附加到与可拖动对象相同的容器中,这就是隐藏它时它会消失的原因。

也许这样的事情会起作用:

$( '.thumb' ).draggable( {
    helper: 'clone',
    appendTo: 'body',
    start: function() {
        $('#container').hide();
    }
} );

希望有帮助。

关于jQuery UI 拖放 - 如何在拖动开始时隐藏原始容器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8388693/

相关文章:

jquery - 如何在没有相同高度的情况下创建 4 列 css float left

python - 使用 pygtk 和 glade 的数据库表的 GUI

java - 使用 Swingworker 不断更新 GUI

jquery - 原型(prototype)和 jQuery 问题 this._each 不是函数

通过ajax的Jquery post数组

javascript - $timeout 是避免 AngularJS 指令中 jQuery 插件呈现问题的唯一/推荐方法吗?

Java:从 GUI 中删除 GUI 对象

jQuery 拖放不允许我拖动到可滚动 div 之外?

WPF 4 拖放视觉元素作为光标

html - 使用 JSON 拖放 HTML5 jQuery : e. dataTransfer.setData()