Home

# Class goog.ui.AutoComplete

This is the central manager class for an AutoComplete instance.

extends goog.events.EventTarget

Instance Method Summary
| `attachInputWithAnchor(?Element inputElement, ?Element anchorElement)` Attaches the autocompleter to a text area or text input element with an anchor element. The anchor element is the element the autocomplete box will be positioned against.
| `attachInputs((Element|null|undefined) var_args)` Attach text areas or input boxes to the autocomplete by DOM reference. After elements are attached to the autocomplete, when a user types they will see the autocomplete drop down.
| `cancelDelayedDismiss()` Cancel the active delayed dismiss if there is one.
| `detachInputs((Element|null|undefined) var_args)` Detach text areas or input boxes to the autocomplete by DOM reference.
| `dismiss()` Clears out the token, rows, and hilite, and calls `renderer.dismiss()`
| `dismissOnDelay()` Call a dismiss after a delay, if there's already a dismiss active, ignore.

`disposeInternal()`

Unattach listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners, it should be something like this:

    MyClass.prototype.disposeInternal = function() {
    MyClass.superClass_.disposeInternal.call(this);
    // Dispose logic for MyClass
    };

| `getIdOfIndex_(number index) ⇒ number` Gets the id corresponding to a particular index. (Does no checking.)
| `getIndexOfId(number id) ⇒ number` Gets the index corresponding to a particular id.
| `getRenderer() ⇒ ?goog.events.EventTarget` Returns the renderer that renders/shows/highlights/hides the autocomplete menu.
| `getRowCount() ⇒ number`
| `getTarget() ⇒ ?Element` Gets the current target HTML node for displaying autocomplete UI.
| `handleEvent(?goog.events.Event e)` Generic event handler that handles any events this object is listening to.
| `hasHighlight() ⇒ boolean` Returns whether or not the autocomplete is open and has a highlighted row.
| `hiliteId(number id) ⇒ boolean` Hilites the id if it's valid, otherwise does nothing.
| `hiliteIndex(number index) ⇒ boolean` Hilites the index, if it's valid, otherwise does nothing.
| `hiliteNext() ⇒ boolean` Moves the hilite to the next row, or does nothing if we're already at the end of the current set of matches. Calls renderer.hiliteId() when there's something to do.
| `hilitePrev() ⇒ boolean` Moves the hilite to the previous row, or does nothing if we're already at the beginning of the current set of matches. Calls renderer.hiliteId() when there's something to do.
| `immediatelyCancelDelayedDismiss_() ⇒ boolean` Cancels any delayed dismiss events immediately.
| `isOpen() ⇒ boolean`

`matchListener_(string matchedToken, !Array rows, boolean= opt_preserveHilited)`

Callback passed to Matcher when requesting matches for a token. This might be called synchronously, or asynchronously, or both, for any implementation of a Matcher. If the Matcher calls this back, with the same token this AutoComplete has set currently, then this will package the matching rows in object of the form

    {
    id: an integer ID unique to this result set and AutoComplete instance,
    data: the raw row data from Matcher
    }

| `renderRows(!Array rows, boolean= opt_preserveHilited)` Renders the rows and adds highlighting.
| `selectHilited() ⇒ boolean` If there are any current matches, this passes the hilited row data to `selectionHandler.selectRow()`
| `setAllowFreeSelect(boolean allowFreeSelect)` Sets whether or not the up/down arrow can unhilite all rows.
| `setAutoHilite(boolean autoHilite)` Sets whether or not the first row should be highlighted by default.
| `setMaxMatches(number max)` Sets the max number of matches to fetch from the Matcher.
| `setTarget(?Element target)` Sets the current target HTML node for displaying autocomplete UI. Can be an implementation specific definition of how to display UI in relation to the target node. This target will be passed into `renderer.renderRows()`
| `setToken(string token, string= opt_fullString)` Sets the token to match against. This triggers calls to the Matcher to fetch the matches (up to maxMatches), and then it triggers a call to `renderer.renderRows()`.
| `setTriggerSuggestionsOnUpdate(boolean triggerSuggestionsOnUpdate)` Sets whether or not to request new suggestions immediately after completion of a suggestion.
| `setWrap(boolean wrap)` Sets whether or not selections can wrap around the edges.
| `update(boolean= opt_force)` Forces an update of the display.