I have read several articles/questions/forums discussing the best auto-complete plugin for jQuery. After trying several good ones, I've realized a flaw in most.
我已经阅读了几篇讨论jQuery最佳自动完成插件的文章/问题/论坛。在尝试了几个好的之后,我发现了大多数的缺陷。
-
If you are looking up countries and type 'In', a couple of countries show up. If you continue typing I-n-d-i-a, this results in 5 AJAX calls (see http://www.freeimagehosting.net/uploads/6f1bcd69e1.png) its quite natural that India is a subset of In, so why call again? We need to simply filter the retrieved list client-side. Anyone knows about such an implementation?
如果您正在查找国家/地区并输入“In”,则会出现几个国家/地区。如果你继续输入I-n-d-i-a,这会导致5个AJAX调用(参见http://www.freeimagehosting.net/uploads/6f1bcd69e1.png)很自然,印度是In的子集,那么为什么再次调用呢?我们需要简单地过滤检索到的列表客户端。有谁知道这样的实现?
-
What is the status of the Jquery Autocomplete feature? I read at * that it is no longer available with Jquery; but the Jquery website has a 'New' mark besides the link to Autocomplete.
Jquery自动填充功能的状态是什么?我在*上读到Jquery不再提供它了;但是除了自动填充的链接之外,Jquery网站还有一个“新”标记。
Thanks
谢谢
2 个解决方案
#1
8
The point you write about in 1. could be because :
你在1.中写的一点可能是因为:
- Searching for '
In
' shoudl return a lot of results - 搜索'In'shoudl会返回很多结果
- There is some limit in place, on the server-side, to never return more than N results
- 在服务器端,存在一些限制,永远不会返回超过N个结果
- Which means the full list of countries contains "
In
" is not known, on the client-side - 这意味着在客户端不知道包含“In”的完整国家列表
- Which implies it's not possible to get (for sure) the list that corresponds to "
Ind
" without another Ajax request. - 这意味着在没有其他Ajax请求的情况下,无法获得(肯定)与“Ind”对应的列表。
A half-solution that's often used is to not send an Ajax request immediatly after a keypress, but only 100 or 200 milliseconds after.
经常使用的半解决方案是在按键后立即发送Ajax请求,但仅在100或200毫秒后发送。
This way, if the user types "Indi
" fast, and waits before typing anything else, the will only be 1 Ajax request, for "Indi
" (and none for "In
", "Ind
")
这样,如果用户快速键入“Indi”,并在键入任何其他内容之前等待,则只有1个Ajax请求,对于“Indi”(并且没有“In”,“Ind”)
#2
3
The jQuery UI autocomplete has been added in the new version 1.8 so as far as I saw in the project activity it is still being developed. There is an example that uses a client side cache concerning the issue you explained. You can use the already mentioned delay option, too.
jQuery UI自动完成已添加到新版本1.8中,因此,就我在项目活动中看到的,它仍在开发中。有一个示例使用客户端缓存来解决您解释的问题。您也可以使用已经提到的延迟选项。
#1
8
The point you write about in 1. could be because :
你在1.中写的一点可能是因为:
- Searching for '
In
' shoudl return a lot of results - 搜索'In'shoudl会返回很多结果
- There is some limit in place, on the server-side, to never return more than N results
- 在服务器端,存在一些限制,永远不会返回超过N个结果
- Which means the full list of countries contains "
In
" is not known, on the client-side - 这意味着在客户端不知道包含“In”的完整国家列表
- Which implies it's not possible to get (for sure) the list that corresponds to "
Ind
" without another Ajax request. - 这意味着在没有其他Ajax请求的情况下,无法获得(肯定)与“Ind”对应的列表。
A half-solution that's often used is to not send an Ajax request immediatly after a keypress, but only 100 or 200 milliseconds after.
经常使用的半解决方案是在按键后立即发送Ajax请求,但仅在100或200毫秒后发送。
This way, if the user types "Indi
" fast, and waits before typing anything else, the will only be 1 Ajax request, for "Indi
" (and none for "In
", "Ind
")
这样,如果用户快速键入“Indi”,并在键入任何其他内容之前等待,则只有1个Ajax请求,对于“Indi”(并且没有“In”,“Ind”)
#2
3
The jQuery UI autocomplete has been added in the new version 1.8 so as far as I saw in the project activity it is still being developed. There is an example that uses a client side cache concerning the issue you explained. You can use the already mentioned delay option, too.
jQuery UI自动完成已添加到新版本1.8中,因此,就我在项目活动中看到的,它仍在开发中。有一个示例使用客户端缓存来解决您解释的问题。您也可以使用已经提到的延迟选项。