Class idx.widget.TypeAhead


Extends dijit._Widget.
This widget provides type ahead feature attached to an existing input element.
Defined in: <idx\widget\TypeAhead.js>.

Constructor Summary

Constructor Attributes Constructor Name and Description
 

Field Summary

Field Attributes Field Name and Description
 
Interval to handle losing focus.
 
Caches the results as an array, if true.
 
Shows a close button, if true.
 
Input element ID or node.
 
encode 
Specifies whether to encode request keyword.
 
Indicates whether pop-up is shown or not.
 
Attribute name for label string.
 
method 
HTTP method for AJAX request.
 
Keeps showing the results even after loosing focus, if true.
 
Specifies whether to use polling for typing with IME.
 
Interval of polling.
 
Query options for fetching from data store.
 
store 
Data store.
 
Timeout for AJAX request.
 
type 
Response type.
 
url 
URL for AJAX request for JSON or HTML.
 
Attribute name for value.

Method Summary

Method Attributes Method Name and Description
 
Aborts AJAX request.
 
attach(id)
Connects to a new node.
 
Sets up event handlers for the connected node.
 
Clears timer for loosing focus.
 
Clears the cache.
 
Clears polling.
 
Clears the results.
 
Initializes internal properties.
 
Destroys the popoup widget and removes event handlers.
 
Disconnects from the connected node.
 
Generates AJAX request content.
 
Retrieves displayed text.
 
Hides the results.
 
jsonToHtml(suggestions)
Converts JSON to HTML.
 
Loads suggestions from the cache.
 
Loads suggestions from data store.
 
Loads suggestions.
 
Callback for loosing focus.
 
Callback for click.
 
Callback for enter.
 
Loads suggestions using AJAX request.
 
renderResults(data, fromCache)
Renders the results.
 
Sets text to display for value.
 
setStore(store)
Sets a new data store.
 
Shows the results.

Constructor Detail

idx.widget.TypeAhead()

Field Detail

{Number} blurInterval

Interval to handle losing focus.
Default Value:
300

{Boolean} cacheEnabled

Caches the results as an array, if true.
Default Value:
true

{Boolean} closable

Shows a close button, if true.
Default Value:
false

{String|Object} connectedNode

Input element ID or node.
Default Value:
""

{boolean} encode

Specifies whether to encode request keyword.
Default Value:
false

{Boolean} isShowing

Indicates whether pop-up is shown or not.
Default Value:
false

{String} labelAttr

Attribute name for label string.
Default Value:
"name"

{String} method

HTTP method for AJAX request. "POST" or "GET".
Default Value:
"POST"

{Boolean} persist

Keeps showing the results even after loosing focus, if true.
Default Value:
false

{boolean} polling

Specifies whether to use polling for typing with IME.
Default Value:
true

{Number} pollingInterval

Interval of polling.
Default Value:
500

{Object} queryOptions

Query options for fetching from data store.

{Object} store

Data store.
Default Value:
null

{Number} timeout

Timeout for AJAX request.
Default Value:
3000

{String} type

Response type. One of "store", "json" and "dom".
Default Value:
"store"

{String} url

URL for AJAX request for JSON or HTML.
Default Value:
""

{String} valueAttr

Attribute name for value.
Default Value:
"value"

Method Detail

abortRequest()

Aborts AJAX request.

attach(id)

Connects to a new node.
Parameters:
{String|Object} id

attachHandlers(node)

Sets up event handlers for the connected node.
Parameters:
node

clearBlurTimer()

Clears timer for loosing focus.

clearCache()

Clears the cache.

clearPollingTimer()

Clears polling.

clearResults()

Clears the results.

constructor()

Initializes internal properties.

destroy()

Destroys the popoup widget and removes event handlers.

detach()

Disconnects from the connected node.

{Object} getContentParam(value)

Generates AJAX request content. Caller or sub-class may override this method.
Parameters:
{String} value
Returns:
{Object}

{String} getDisplayedValue()

Retrieves displayed text.
Returns:
{String}

hideResults()

Hides the results.

{String} jsonToHtml(suggestions)

Converts JSON to HTML. Caller or sub-class may override this method for custom rendering.
Parameters:
{Array} suggestions
Returns:
{String}

loadFromCache(value)

Loads suggestions from the cache.
Parameters:
{String} value

loadStoreSuggestions(value)

Loads suggestions from data store.
Parameters:
{String} value

loadSuggestions(value)

Loads suggestions.
Parameters:
{String} value

onBlur()

Callback for loosing focus.

onClick(e)

Callback for click.
Parameters:
{Object} e

onExecute()

Callback for enter.

remoteLoadSuggestions(value)

Loads suggestions using AJAX request.
Parameters:
{String} value

renderResults(data, fromCache)

Renders the results.
Parameters:
{Object} data
{Boolean} fromCache

setDisplayedValue(value)

Sets text to display for value.
Parameters:
{String} value

setStore(store)

Sets a new data store.
Parameters:
{Object} store

showResults()

Shows the results.