Class: AutoComplete

AutoComplete

new AutoComplete(uri, opt_multi, opt_renderer, opt_inputId, opt_xhrIo, opt_xmlHttpFactory, opt_useSimilar, opt_domHelper)

This class is a wrapper around goog.ui.ac.AutoComplete that uses a remote object matcher. The remote object matcher can retrieve autocomplete suggestions as plain strings, or, custom objects. It is best if the objects have a 'caption' property. This property is used to display the suggestions. If an object does not have a 'caption' property, 'toString' is used instead.
Parameters:
Name Type Argument Description
uri goog.Uri The server resources to use for fetching a list of suggestions. You can add custom parameters to uri to pass to the server with every request
opt_multi boolean <optional>
Whether to allow multiple entries separated with semi-colons or commas
opt_renderer plana.ui.ac.AutoCompleteRenderer <optional>
An optional renderer that extends the default renderer, i.e. implements a 'createDom' and 'getInput' method
opt_inputId string <optional>
Optional id to use for the autocomplete input element
opt_xhrIo goog.net.XhrIo <optional>
Optional XhrIo object to use. By default we create a new instance
opt_xmlHttpFactory goog.net.XmlHttpFactory <optional>
Optional factory to use when creating XMLHttpRequest objects
opt_useSimilar boolean <optional>
Use similar matches. e.g. "gost" => "ghost". This option is passed along to the server
opt_domHelper goog.dom.DomHelper <optional>
The dom helper
Source:

Extends

  • goog.ui.Component

Members

<static> MSG_LOADING_DEFAULT

Default loading message while fetching results
Source:

<static> MSG_NO_MATCHES_FOUND

Default message if no matches were found on the server
Source:

<static> PLACEHOLDER_ROW_CSS :string

The class name of the row showing loading and no match found messages
Type:
  • string
Source:

<protected> autoComplete :goog.ui.ac.AutoComplete

The actual autocomplete component
Type:
  • goog.ui.ac.AutoComplete
Source:

<protected> cachingMatcher :plana.ui.ac.CachingObjectMatcher

The matcher that combines a local cache of matches with the remote matcher
Type:
Source:

<protected> componentRenderer :plana.ui.ac.AutoCompleteRenderer

Custom renderer for this class. Its main job is to attach custom classes to the container and its input element
Type:
Source:

<protected> inputHandler :plana.ui.ac.InputHandler

The input handler that updates the text input when a match is selected
Type:
Source:

Methods

canDecorate(element) → {boolean}

This component does not support decoration for now
Parameters:
Name Type Description
element Element Element to decorate
Source:
Returns:
Return false
Type
boolean

createDom()

Source:

disposeInternal()

Source:

enterDocument()

Source:

exitDocument()

Source:

focus()

This function sets the focus to the text input
Source:

getAutoComplete() → {goog.ui.ac.AutoComplete}

This function returns the actual autocomplete UI
Source:
Returns:
Type
goog.ui.ac.AutoComplete

getCachingMatcher() → {plana.ui.ac.CachingObjectMatcher}

This function returns the cached-based remote matcher used by this component
Source:
Returns:
Type
plana.ui.ac.CachingObjectMatcher

getInputHandler() → {plana.ui.ac.InputHandler}

This function returns the input handler used by the autocomplete UI
Source:
Returns:
Type
plana.ui.ac.InputHandler

getModel() → {Object|string|null|Array.<(Object|string)>}

Source:
Returns:
Type
Object | string | null | Array.<(Object|string)>

getNonMatches() → {Array.<string>}

It is possible when a user pastes text in the textbox, and the autocomplete supports separators, that #getModel does not return the list of items that are displayed in the textbox. For example, if a user pastes complete,non-matching nonsense the input handler will not return any matches. Use this function to get the list of entries displayed in the textbox that have not been matched with a server result.
Source:
Returns:
Type
Array.<string>

getRenderer() → {plana.ui.ac.AutoCompleteRenderer}

This function returns the renderer used to render this component (i.e. wrap the input element inside a div)
Source:
Returns:
Type
plana.ui.ac.AutoCompleteRenderer

<protected> hidePlaceHolders()

This function removes any loading or no-match messages
Source:

<protected> onKey(e)

Callback for KEY events dispatched by the input element associated with this autocomplete. Here we listen for up/down and tab keys to navigate the suggestion list, and for the enter key to select a highlighted item
Parameters:
Name Type Description
e goog.events.KeyEvent The key event dispatched by the key handler of the input handler control. The key event is forwarded to here because we set the parent event target of this.inputHandler
Source:

setHeaders(headers)

Set the HTTP headers. Wrapper around plana.ui.ac.RemoteObjectMatcher#setHeaders
Parameters:
Name Type Argument Description
headers Object <nullable>
Source:

setLoadingContent(content)

This function sets the content to show while fetching matches from the server
Parameters:
Name Type Description
content Element | string | null
Source:

setModel(model)

Parameters:
Name Type Description
model * The list of objects or string with which to initialize the text input of the autocomplete input
Source:

setNoMatchContent(content)

This function sets the content to show if the token does not match anything
Parameters:
Name Type Description
content Element | string | null
Source:

setPlaceholder(label)

Setter for the placeholder text of the input
Parameters:
Name Type Description
label string
Source:

setPreventDefaultOnTab(newValue)

Parameters:
Name Type Description
newValue boolean Whether to preventDefault on TAB.
Source:
See: