Jquery-based AutoComplete is an automatic query completion plug-in. Based on user input, it communicates with the background in real time through Ajax, and returns appropriate content to generate a selectable list for use to complete the completion auxiliary function. It has more detailed options to set. If you want to use it, you can first look at the official instructions.
This article discusses the necessary modifications as needed. For example, to reduce unnecessary queries and reduce the pressure on databases and servers for frequent searches, the use of minchars is very limited.
In the following method, you can modify the JQ. AutoComplete source code to change the key processing logic, move the Enter key function to a vacant Tab key, and use the return key as the function key for manual query. Normal buttons will no longer stimulate queries.
1. Open JQ. AutoComplete and find case key. Tab:
2. After finding it, replace the following code with the corresponding location of the source code:
Case key. tab: If (selectcurrent () {// stop default to prevent a form submit, opera needs special handling event. preventdefault (); blocksubmit = true; return false;} break; Case key. return: cleartimeout (timeout); timeout = setTimeout (onchange, options. delay); break; default: break;
Reprinted please indicate from http://blog.csdn.net/theforever/article/details/8053963
If there is time, you can rewrite this function to an extension option of JQ. AutoComplete to control whether to query automatically or manually. You only need to add an option and make judgments in the three cases. This is just a solution to a specific question, and you are not in the mood to write anything else (you have done the same for a long time ). If you are interested, you can perform expansion on your own.