根据返回的记录将字段呈现为 jQuery 自动完成或下拉列表
业务要求: 用于上传文档并为来自外部数据库的文档分配属性的表单。有 10 个表单字段,当用户在表单上填写值时,其他字段会被实时过滤。即,如果他们选择“美国”作为国家/地区,则州/省字段仅允许美国各州。
用户体验挑战: 其中许多字段都以数百万个可能的值开始,因此我为它们使用了 jQuery 自动完成功能。当字段被过滤时,可能的选项数量会下降到下拉列表可以更好地提供服务的数量。
问题: 一旦选项数量低于一定数量,有没有办法动态地将 jQuery 自动完成字段更改为下拉框?我查看了 jQuery 自动完成选项,但我不想用超过 100 万条记录填充组合框,即使用户看不到全部记录。
Business Requirement:
Form to upload a document and assign attributes to the document that are sourced from an external database. There are 10 form fields and as the user fills in values on the form, the other fields are filtered in real time. I.e. If they select "United States" for country, the state / province field only allows US states.
UX Challenge:
Many of these fields start off with literally millions of possible values so I used jQuery autocomplete for them. As the fields are filtered the number of possible options drop to a number that would be better serviced by a drop-down list.
Question:
Is there a way to dynamically change a jQuery autocomplete field to a dropdown box once the number of options drop below a certain number? I looked at the jQuery autocomplete option but I don't want to fill a combobox with 1 million+ records even if the user won't see them all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试给
ul
一个明确的高度并将overflow
设置为scroll
You could try to give the
ul
an explicit height and set theoverflow
toscroll
我从 UI/UX 角度解决了这个问题。我有一个后台功能,可以让我知道每个字段可用的选项数量。有了这些信息,我可以通过编程方式更改最小长度和延迟选项。我还绑定/取消绑定焦点事件的函数并适当地设置它的样式(感谢@Interstellar_Coder)。这为用户提供了与下拉列表相关的即时响应。
下面是我正在做的事情的简单版本。我使用按钮单击事件来模仿我在实际应用程序中以编程方式执行的操作。
I solved the issue for a UI / UX perspective. I have a background function that lets me know the number of options available for each field. With that information I programmatically change the minlength and delay option. I also bind / unbind a function for the focus event and style it (thanks @Interstellar_Coder) appropriately. This gives the user the immediate response associated with a dropdownlist.
Below is simple version of what I'm doing. I'm using button click events to mimic what I'm doing programmatically in my actual application.