带有滚动条 z-index 帮助的 jQuery UI 自动完成
我有一个文本框,我将 jQuery UI 的自动完成功能附加到其中,并使用 CSS 通过示例 此处。我的问题是,这样做会导致 bgiframe 解决的 z-index 问题再次出现,但以不同的方式。初始自动完成菜单位于其下方的所有控件之上,但是当我开始滚动时,自动完成菜单落在它们后面。
有什么建议吗?
编辑:
这纯粹是 IE6 的错误。
正如您所看到的,向下滚动后,自动完成功能落后于其他控件。
I have a textbox that I am attaching jQuery UI's Autocomplete functionality to and I am using CSS to give it a max height via the example here. My problem is that doing this causes the z-index problem that bgiframe solves to come back again, but in a different way. The initial autocomplete menu is above all the controls underneath it, but when I begin to scroll the autocomplete menu falls behind them.
Any suggestions?
EDIT:
This is purely an IE6 bug.
As you can see, after scrolling down the autocomplete falls behind the other controls.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我可以通过在以下行(来自 jquery.bgiframe.js)中将 offsetHeight 替换为 scrollHeight 来解决问题:
height:'+(s.height== 'auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
此更改解决了带有垂直滚动条的自动完成字段的错误。我无法在其他类型的对话框中发现任何回归(但我没有进行广泛的测试)。
I could solve the problem by replacing offsetHeight by scrollHeight in the following line (from jquery.bgiframe.js) :
height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
This change solved the bug for the autocomplete fields with vertical scrollbars. I could not spot any regression in other kinds of dialogs (but I did not run extensive tests).
您需要使用 javascript 反转表单元素(或其容器)的 z-index 顺序。即,“社会工作者”的 z 指数最低,“DX 代码”的 z 指数最高。
You need to reverse the z-index order of the form elements (or their containers) using javascript. I.e., "Social Worker" has the lowest, "DX Code" the highest z-index.
您可以将offsetHeight更改为scrollHeight,就像Siggen所说,但是当自动完成仅返回1个结果时,我遇到了问题。第 1 个结果被压缩到一个仅 2 px 高的窗口中。
不过我找到了解决方法。
当 data.length<2 时,您应该使用 offsetHeight,而不是scrollHeight。
您必须修改 autocomplete.js。
并使其如下:
记住,此代码应与 Siggen 的修复结合使用。
You could change the offsetHeight to scrollHeight, like Siggen says, but I have encountered problems when there is only 1 result returned from the autocomplete. The 1 result is squished into a window that only like 2 pxs high.
I found a fix though.
When you have a data.length<2, you should use the offsetHeight, rather than the scrollHeight.
You have to modify autocomplete.js.
And make it this:
Remember, this code should be used in combination with Siggen's fix.
我将两个参数的组合用于高度,如下所示:
'height:'+(s.height=='auto'?'expression(Math.max(this.parentNode.offsetHeight,this.parentNode.scrollHeight) )+\'px\')':prop(s.height))+';'
看一下 max 函数。现在没有滚动条了(列表也更短,列表也更长)
,现在自动完成组件在 IE6 中看起来很完美。
I have used a combination of both parameter for the height like this:
'height:'+(s.height=='auto'?'expression(Math.max(this.parentNode.offsetHeight,this.parentNode.scrollHeight)+\'px\')':prop(s.height))+';'
Look at the max function. Now it is good with no scroll bar (shorter list and longer list as well)
and now the autocomplete component looks perfect in IE6.