帮助 Jquery 自动完成 - 即将完成
我一直在自定义 Jquery UI 自动完成功能,以确保用户仅提交来自 geonames 数据源的数据。
选择城市名称后,我还从 geonames web 服务中检索国家/地区、纬度和经度,并添加它们隐藏的输入。
为了确保人们实际从建议列表中选择城市,如果您单击建议列表之外的位置,我会清除输入。
(我还在 php 中进行了一些验证)
问题:单击建议列表后,当您键入城市名称时,除非按空格键,否则它不会重新出现。我不确定是什么原因造成的。此外,当您输入带有空格的城市时,有时建议列表会消失。
有人可以分享一些指导吗?我也欢迎任何其他建议!
I've been customizing the Jquery UI auto-complete to ensure that users submit only data from the geonames datasource.
Upon selecting a city name I also retrieve the country, latitude, and longitude from the geonames webservice and add them to hidden inputs.
To ensure that people actually select a city from the suggestion list, I clear the input if you click away from the suggestion list.
(I'm also doing some validation in php)
The issue: after clicking out of the suggestion list, it does not reappear when you type a city name unless you press the spacebar. I'm not sure what is causing this.. Also when you type a city with spaces, sometimes the suggestion list disappears.
Could someone please share some guidance? I also welcome any other suggestions!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自动完成插件曾经有一个名为“mustMatch”的选项 - 它做了您想要的事情,但现已被删除。
我相信您可以按照以下说明重新实现它:
如何在 jQuery UI 自动完成中实现“mustMatch”和“selectFirst”?
另一个选项:
用以下丑陋的内容替换您的更改(在修改后的小提琴中)或关闭(在原始小提琴中)解决方法:
The autocomplete plugin used to have an option called "mustMatch" - It did what you wanted but has since been removed.
I believe you can re-implement it by following these instructions:
How to implement "mustMatch" and "selectFirst" in jQuery UI Autocomplete?
ANOTHER OPTION:
replace your change (in your revised fiddle) or close (in original fiddle) with the following ugly workaround: