Http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete
Current version: 1.1
JQuery version: 1.2.6 +
The first is the most important method.
Autocomplete (url or data, [options])
The first parameter can be an array or url. The options parameter is complex:
* MinChars (Number ):
The number of characters that the user must enter before triggering autoComplete. Default: 1. If it is set to 0, double-click the input box or delete the content in the input box to display the list.
* Width (Number ):
Width of the drop-down box. Default: width of the input element
* Max (Number ):
AutoComplete drop-down shows the number of projects. Default: 10
* Delay (Number ):
The delay time (in milliseconds) for activating autoComplete after the key is clicked. Default: the remote value is 400 local 10
* AutoFill (Boolean ):
Do you want to automatically enter the user's current mouse value in the input box when the user selects it? Default: false
* MustMatch (Booolean ):
If it is set to true, autoComplete will only allow matching results to appear in the input box. If the user inputs illegal characters, the drop-down box will not be available. Default: false
* MatchContains (Boolean ):
Determine whether to check the match within the string during comparison, for example, whether ba matches the ba in foo bar. It is important to use cache. Do not mix it with autofill. Default: false
* SelectFirst (Boolean ):
If it is set to true, the first value of the autoComplete drop-down list is automatically selected when you type the tab or return key, although it is not manually selected (with a keyboard or mouse ). of course, if you select a project, you can use the selected value. default: true
* CacheLength (Number ):
The cache length, that is, the number of records to be cached in the result set obtained from the database. set to 1 as not cached. Default: 10
* MatchSubset (Boolean ):
AutoComplete can be used to cache server queries. If the query result of foo is cached, you do not need to retrieve foo if you enter foo. this option is usually enabled to reduce the burden on the server and improve performance. it is valid only when the cache length is greater than 1. default: true
* MatchCase (Boolean ):
Whether the case sensitivity switch is enabled for comparison. it is important to use the cache. if you understand the previous option, this is not difficult to understand, just like whether foot needs to be searched in the FOO cache. default: false
* Multiple (Boolean ):
Whether multiple values can be input. That is, multiple autoComplete values can be used to input multiple values. Default: false
* MultipleSeparator (String ):
If multiple characters are selected, they are used to separate the selected characters. Default :","
* Scroll (Boolean ):
Whether to use Scroll display when the result set is larger than the Default height Default: true
* ScrollHeight (Number ):
The scroll height of the Automatic completion prompt is expressed in pixels by Default: 180
* FormatItem (Function ):
Use advanced labels for each project to be displayed. this function is called for each row in the result. The returned value is contained in the LI element and displayed in the drop-down list. autocompleter will provide three parameters (row, I, max): The returned result array, the number of rows processed currently (that is, the number of items, which is a natural number starting from 1 ), the number of elements in the current result array is the number of items. default: none, indicating that no custom processing function is specified, so that each row in the drop-down list contains only one value.
* FormatResult (Function ):
Similar to formatItem, You Can format the value to be entered in the input text box. there are also three parameters, the same as formatItem. default: none, which indicates either data only or the value provided by formatItem.
* FormatMatch (Function ):
Use this function to format the data format to be queried for each row of data. The return value is used by the internal search algorithm. The parameter value row
* ExtraParams (Object ):
Provides more parameters for the backend (generally server scripts. like the common practice, a key-Value Pair object is used. if the passed value is {bar: 4}, it will be parsed into my_autocomplete_backend.php by autocompleter? Q = foo & bar = 4 (assuming the current user has entered foo). Default :{}
Result (handler, item)
The selected event. Item is the selected phase.
For example, we can directly jump to the page after selection:
Copy codeThe Code is as follows:
Var data = [{text: 'link A', url: '/page1'}, {text: 'link B ', url:'/page2'}];
$ ("..."). Autocomplete (data ,{
FormatItem: function (item ){
Return item. text;
}
}). Result (function (event, item ){
Location. href = item. url;
});
Document address: http://docs.jquery.com/Plugins/Autocomplete#API_Documentation
Use the instance code:
Example of how Jquery AutoComplete is used automatically