O'Reilly logo

jQuery UI by Eric Sarrion

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The autocomplete () Method

The autocomplete () method can be used in two forms:

  • $(selector, context).autocomplete (options)

  • $(selector, context).autocomplete ("action", params)

The autocomplete (options) Method

The autocomplete (options) method declares that an <input> HTML element must be managed as an input field that will be displayed above a list of suggestions. The options parameter specifies the behavior of the list of suggestions when the user is typing in the input field.

The operation of autocompletion is as follows: from the characters introduced in the input field, a match is made in the specified source (in options.source). Matching can be done with any character from the source, not just the beginning of it. Thus, if one looks for the letter “a,” it does not have to be located at the beginning of words, but can be located in the middle.

Managing autocompletion

Table 9-1 details the options that are available for managing autocompletion.

Table 9-1. Options for managing autocompletion

Option

Function

options.disabled

When set to true, disables the autocompletion mechanism. Users can enter characters into the text field, but no list appears. Use autocomplete ("enable") to enable the autocompletion mechanism.

options.source

Indicates the data source to use for the list of suggestions. Data can be local (already known in the program) or remote (retrieved from the server).

options.minLength

Minimum number of characters to enter in the field to start the display of the list of suggestions. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required