jQuery Ui:无法从Div中拖动元素到溢出 [英] jQuery Ui: Cant drag element from Div with overflow

查看:47
本文介绍了jQuery Ui:无法从Div中拖动元素到溢出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在div中有一个简单的UL,溢出设置为自动且固定高度.每个LI均可通过jQuery拖动. 问题是我无法将它们从div拖动(当拖动到边界时它们会消失).

I have a simple UL in a div with the overflow set to automatic and a fixed height. Each LI is draggable via jQuery. Problem is that I cannot drag them from the div (they disappear when dragged to the boundaries).

我已经看过这个问题及其答案,但是这里的解决方案似乎对我不起作用(设置滚动选项): jQuery可拖动和溢出问题

I have looked at this question and its answers, but the solution here does not seem to work for me (setting the scroll option): jQuery Draggable and overflow issue

谢谢

推荐答案

我通过使用辅助方法将项目附加到主体(因此它位于div之外)来解决了这个问题

I got around this by using a helper method to append the item to the body (so its outside the div)

$("#myitem").draggable({
helper: function() { return $(this).clone().appendTo('body').show(); }
});

不确定是否需要show(),我还必须提高z索引,但这取决于页面的其余部分.

Not sure if you need the show() and I also had to raise the z-index but it depends on the rest of your page.

菲尔

这篇关于jQuery Ui:无法从Div中拖动元素到溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆