Mixin: LookupElement

.ui.mixin.LookupElement

LookupElement is a mixin that creates a menu of suggested values for a text input widget. Suggested values are based on the characters the user types into the text input field and, in general, the menu is only displayed when the user types. If a suggested value is chosen from the lookup menu, that value becomes the value of the input field.

Note that a new menu of suggested items is displayed when a value is chosen from the lookup menu. If this is not the desired behavior, disable lookup menus with the #setLookupsDisabled method, then set the value, then re-enable lookups.

See the OOjs UI demos for an example.

Mixes In:
Source:

Methods

(abstract, protected) getLookupCacheDataFromResponse(response) → {Mixed}

Pre-process data returned by the request from #getLookupRequest.

The return value of this function will be cached, and any further queries for the given value will use the cache rather than doing API requests.

Parameters:
Name Type Description
response Mixed

Response from server

Source:
Returns:

Cached result data

Type
Mixed

(abstract, protected) getLookupMenuOptionsFromData(data) → {Array.<OO.ui.MenuOptionWidget>}

Get a list of menu option widgets from the (possibly cached) data returned by

#getLookupCacheDataFromResponse.

Parameters:
Name Type Description
data Mixed

Cached result data, usually an array

Source:
Returns:

Menu items

Type
Array.<OO.ui.MenuOptionWidget>

(abstract, protected) getLookupRequest() → {jQuery.Promise}

Get a new request object of the current lookup query value.

Source:
Returns:

jQuery AJAX object, or promise object with an .abort() method

Type
jQuery.Promise

getRequest()

Source:

getRequestCacheDataFromResponse()

Source:

getRequestQuery()

Source:

(protected) onLookupInputBlur(e)

Handle input blur event.

Parameters:
Name Type Description
e jQuery.Event

Input blur event

Source:

(protected) onLookupInputChange(value)

Handle input change event.

Parameters:
Name Type Description
value string

New input value

Source:

(protected) onLookupInputFocus(e)

Handle input focus event.

Parameters:
Name Type Description
e jQuery.Event

Input focus event

Source:

(protected) onLookupInputMouseDown(e)

Handle input mouse down event.

Parameters:
Name Type Description
e jQuery.Event

Input mouse down event

Source:

(protected) onLookupMenuItemChoose(item)

Handle menu item 'choose' event, updating the text input value to the value of the clicked item.

Parameters:
Name Type Description
item OO.ui.MenuOptionWidget

Selected item

Source:

(protected) onLookupMenuToggle(visible)

Handle the lookup menu being shown/hidden.

Parameters:
Name Type Description
visible boolean

Whether the lookup menu is now visible.

Source:

setLookupsDisabled(disabled)

Disable or re-enable lookups.

When lookups are disabled, calls to #populateLookupMenu will be ignored.

Parameters:
Name Type Description
disabled boolean

Disable lookups

Source:

setReadOnly(readOnly)

Set the read-only state of the widget.

This will also disable/enable the lookups functionality.

Parameters:
Name Type Description
readOnly boolean

Make input read-only

Source: