jquery.autocomplete插件简介(续)

本文详细介绍了AutoComplete组件的各项参数配置及其作用,包括最小字符数、延迟时间、缓存长度等,帮助开发者更好地理解和使用AutoComplete。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

对autocomplete的一些参数进行说明

Options:

NameType
minCharsNumber Default: 1

执行autocomplete的最小值

The minimum number of characters a user has to type before the autocompleter activates.

delayNumber Default: 400 for remote, 10 for local

显示自动自动完成选择框的延迟时间

The delay in milliseconds the autocompleter waits after a keystroke to activate itself.

cacheLengthNumber Default: 10

缓存长度

The number of backend query results to store in cache. If set to 1 (the current result), no caching will happen. Must be >= 1.

matchSubsetBoolean Default: true

匹配子集

Whether or not the autocompleter can use a cache for more specific queries. This means that all matches of "foot" are a subset of all matches for "foo". Usually this is true, and using this options decreases server load and increases performance. Only useful with cacheLength settings bigger than one, like 10.

matchCaseBoolean Default: false

是否敏感的比较。

Whether or not the comparison is case sensitive. Important only if you use caching.

matchContainsBoolean Default: false

匹配内容。

Whether or not the comparison looks inside (i.e. does "ba" match "foo bar") the search results. Important only if you use caching. Don't mix with autofill.

mustMatchBoolean Default: false

必须完全匹配。

If set to true, the autocompleter will only allow results that are presented by the backend. Note that illegal values result in an empty input box.

selectFirstBoolean Default: true

如果设置为true则第一个值会被自动选中。

If this is set to true, the first autocomplete value will be automatically selected on tab/return, even if it has not been handpicked by keyboard or mouse action. If there is a handpicked (highlighted) result, that result will take precedence.

extraParamsObject

额外的参数。

Extra parameters for the backend. If you were to specify { bar:4 }, the autocompleter would call my_autocomplete_backend.php?q=foo&bar=4 (assuming the input box contains "foo"). The param can be a function that is called to calculate the param before each request.

formatItemFunction Default: Assumes that a single row contains a single value.

格式化结果内容

Provides advanced markup for an item. For each row of results, this function will be called. The returned value will be displayed inside an LI element in the results list. Autocompleter will provide 4 parameters: the results row, the position of the row in the list of results (starting at 1), the number of items in the list of results and the search term.

formatMatchFunction Default: formatItem is used

格式化匹配项

Use this option if you want to limit the data that autocomplete searches for matches. For example, there may be items you want displayed to the user, but don't want included in the data that's searched. Gets called with the same arguments as formatItem.

formatResultFunction Default: Assumes either plain data to use as result or uses the same value as provided by formatItem.

格式化结果

Similar to formatItem, but provides the formatting for the value to be put into the input field. Again three arguments: Data, position (starting with one) and total number of data.

multipleBoolean Default: false

是否允许多选

Whether to allow more than one autocompleted-value to enter.

multipleSeparatorString Default: ", "
Seperator to put between values when using multiple option.
widthNumber Default: width of the input Element
选择框的宽度
autoFillBoolean Default: false
当选中自动提示框里面的选项时INPUT框内是否自动补全
maxNumber Default: 10
自动完成提示的显示数量
highlightBoolean , Function Default: Wraps the search term in a <strong> Element

高亮显示当匹配到选择框的元素。

Whether and how to highlight matches in the select box. Set to false to disable. Set to a function to customize. The function gets the value as the first argument and the search term as the second and must return the formatted value.

scrollBoolean Default: true
当结果集大于默认高度时是否使用卷轴显示
scrollHeightNumber Default: 180
自动完成提示的卷轴高度用像素大小表示
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值