JQuery Sortable - 处理 IE 中的错误?
我有一个 div 列表,我希望能够对其进行排序。每个 div 中都有文本,并且内部还有一个句柄(由于 UI,我只想在拖动列表项的左半部分时进行排序)。在 Chrome/FireFox 中,这效果很好,但在 IE 中,如果您单击文本,它不会让您排序,即使文本位于句柄内。
我在这里有一个问题的简化模型,请确保使用 Internet Explorer 进行测试: http://jsfiddle.net/ t8Ebd/
我假设这是一个分层的事情,但尝试了以下方法但没有成功:
- 更改文本的 z 索引并处理
- $(".itemname").disableSelection();
- ms-用户选择:无;用户选择:无;
- 将文本类添加到句柄列表中 - 这解决了问题,但对我不起作用,因为我不希望列表项右半部分的文本触发排序
- 在句柄上设置背景颜色 - 我知道这一点听起来很奇怪,但如果我设置一种颜色,那么它就会成为最上面的元素,从而正确地运行,尽管它隐藏了对我不起作用的文本。
大家还有其他想法吗??
I have a list of divs that I want to be able to sort. Each div has text in it, and also a handle inside of it (due to the UI, I only want to sort if the left half of the list item is dragged). In Chrome/FireFox this works great, but in IE if you click on the text it won't let you sort, even though the text is within the handle.
I have a stripped down mockup of the problem here, make sure you use Internet Explorer to test: http://jsfiddle.net/t8Ebd/
I'm assuming this is a layering thing, but have tried the following approaches with no luck:
- Changing z-indexes of text and handle
- $(".itemname").disableSelection();
- ms-user-select: none; user-select:none;
- adding the text class to the list of handles - this solves the problem, but will not work for me since I don't want the text on the right half of the list item to trigger sorting
- Setting background color on the handle - I know this sounds weird, but if I set a color then it becomes the top most element and thus acts correctly, although it hides the text which won't work for me.
Anyone have any other ideas??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在“.sorthandle”后面有一个额外的逗号,在 IE 中会中断:
将其更改为:
我在评论中建议使用 jQuery UI 中的方法
disableSelection()
。尽管它似乎也不太有效。我已经通过将手柄的背景颜色设置为零并将不透明度设置为零来实现您想要的目标:
DEMO
当然这会删除你的绿色边框,我不知道这是否重要。
也许这可以通过使用 png 透明背景图像来实现。我的猜测是手柄没有背景,IE 选择下面的文本。
You've got an extra comma after ".sorthandle" that breaks in IE:
Change it to:
I have suggested in the comment to use the method
disableSelection()
from jQuery UI. Although it does not seem to quite work neither.I have managed to achieve what you're after by setting a background-color to the handle and the opacity to zero so it's invisible:
DEMO
Of course this removes your green border, I don't know if this is important or not.
Maybe this would work by using a png transparent background-image. My guess is that the handle having no background, IE selects the text underneath.
将布局更改为:(有点黑客)
并添加此 css:
如果您想将边框保留在排序句柄上,请使用此
change your layout to: (kind of a hack)
and add this css:
USE THIS IF you want to keep the border on the sorthandle