在其他元素之上显示 JQuery UI 自动完成建议
我使用 JQuery UI 自动完成在地图控件上建议不同的城市。我通常会让其他 div 显示干扰自动完成建议的内容。 div 显示在建议的顶部。
更改这些 div 的 z-index 是有意义的,因为建议具有最低的 z-index。
选择的策略是修改建议的 z-index 以显示在顶部。这个想法是将一个处理程序附加到建议的加载事件,将 z-index 更改为最高值。由于建议在控件创建时不可用,因此必须使用 .live() 附加处理程序。我已经完成了以下操作:
$('ul.ui-autocomplete').live('load',function(){
this.css('z-index',3999);
});
问题似乎是我没有很好地附加处理程序,因为它没有被解雇。有什么想法吗?
I'm using JQuery UI Autocomplete to suggest different cities on a map control. I usually have other divs showing content that interfere with the suggestions from the autocomplete. The divs appear on top of the suggestions.
Changing the z-index of these divs is pointles for the suggestions have the lowest z-index.
The chosen strategy is to modify the z-index of the suggestions to appear on top. The idea is to attach a handler to the load event of the suggestions that changes the z-index to the highest value. As suggestions are not available at control creation time, the handler must be attached using .live(). I've done the following:
$('ul.ui-autocomplete').live('load',function(){
this.css('z-index',3999);
});
The problem seems that I'm not attaching the handler well as it's not getting fired. Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了一种解决方法来使其发挥作用。我不太喜欢它,因为它取决于对下拉列表的搜索时间几秒钟以“确保”它可用。您需要这个,因为当触发打开事件时,下拉列表尚未创建。如果您将以下函数注册到打开事件,
尽管这有效,但我仍在寻找确定性响应。
I have found a workaround to make it work. I do not really like it as it depends on timing the search of the dropdown list a few seconds to "ensure" it will be available. You need this because when open event is triggered the dropdownlist hasnt been created yet. If you register the following function to the open event
though this works, i'm still looking for a deterministic response.
使用以下代码行的此选项:
use this option below line of code: