从结果中选择时,jQuery 自动完成结果下的输入被激活
当我开始输入物种名称时,我正在寻找带有下拉菜单和一些结果的 jQuery 自动完成小部件。伟大的!!
唯一的问题是,当我从列表中选择一个项目时,“位于该列表项下的输入元素被激活”。并导致顶部出现一个 Android 原生下拉菜单。我尝试在自动完成结果框和输入元素上使用 z 索引。都不起作用。
有人有什么想法吗?
When I start typing in the name of the species I am looking for the jQuery autocomplete widget comes with a dropdown and some results. Great!!
The only problem is that when I select an item from the list the "input element that is located under that list item gets activated". And results in an android native dropdown over the top. I have tried to use z-indexes on the autocomplete results box and on the input elements. Neither work.
Any ideas anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,传播和 z 索引似乎都不能解决问题。
我发现的唯一方法是将其他字段(除了自动完成的字段之外的所有字段)设置为禁用模式。
因此,当自动完成框打开时,我将所有其他输入设置为禁用,并在框关闭后重置它们:
您可以改进上面的代码,例如,通过将要禁用的元素放入数组等中,但基本逻辑保持不变相同:禁用元素,以便 android 在激活自动完成框时不会突出显示它们,并在自动完成框退出后重新启用它们。
Well, nor propagation nor z-indexes seem to solve the problem.
The only way I found is to set other fields (that's all except for one being auto-completed) to disabled mode.
So, when auto-complete box is opened, I set all other inputs to disabled, and reset them once the box closes:
You can improve the code above, say, by putting elements to be disabled into array etc, but the basic logic stays the same: disable elements, so that android doesn't highlight them when auto-complete box is activated, and re-enable them once auto-complete box is out.
取消事件传播可能是解决此问题的关键。这个问题可能有助于解决您遇到的问题。 Javascript 中的事件传播
这也可能有用:http://www.quirksmode.org/js/events_order.html
Canceling event propagation might be a key to solving this. This question might help solve the problem you are running into. Event propagation in Javascript
This may also prove useful: http://www.quirksmode.org/js/events_order.html