Class: ComboBoxInputWidget

.ui.ComboBoxInputWidget(configopt)

new ComboBoxInputWidget(configopt)

ComboBoxInputWidgets combine a text input (where a value can be entered manually) and a menu of options (from which a value can be chosen instead). Users can choose options from the combo box in one of two ways: - by typing a value in the text input field. If the value exactly matches the value of a menu option, that option will appear to be selected. - by choosing a value from the menu. The value of the chosen option will then appear in the text input field. After the user chooses an option, its `data` will be used as a new value for the widget. A `label` also can be specified for each option: if given, it will be shown instead of the `data` in the dropdown menu. This widget can be used inside an HTML form, such as a OO.ui.FormLayout. For more information about menus and options, please see the [OOUI documentation on MediaWiki][1].
Parameters:
Name Type Attributes Description
config Object <optional>
Configuration options
Properties
Name Type Attributes Default Description
options Array.<Object> <optional>
[] Array of menu options in the format `{ data: …, label: … }`
menu Object <optional>
Configuration options to pass to the menu select widget.
$overlay jQuery <optional>
Render the menu into a separate layer. This configuration is useful in cases where the expanded menu is larger than its containing `
`. The specified overlay layer is usually on top of the containing `
` and has a larger area. By default, the menu uses relative positioning. See .
Source:
Examples
// Example: A ComboBoxInputWidget.
    var comboBox = new OO.ui.ComboBoxInputWidget( {
        value: 'Option 1',
        options: [
            { data: 'Option 1' },
            { data: 'Option 2' },
            { data: 'Option 3' }
        ]
    } );
    $( 'body' ).append( comboBox.$element );

    
// Example: A ComboBoxInputWidget with additional option labels.
    var comboBox = new OO.ui.ComboBoxInputWidget( {
        value: 'Option 1',
        options: [
            {
                data: 'Option 1',
                label: 'Option One'
            },
            {
                data: 'Option 2',
                label: 'Option Two'
            },
            {
                data: 'Option 3',
                label: 'Option Three'
            }
        ]
    } );
    $( 'body' ).append( comboBox.$element );

[1]: https://www.mediawiki.org/wiki/OOUI/Widgets/Selects_and_Options#Menu_selects_and_options

Extends

Methods

encapsulateContent(pre, post)

Insert new content either side of a selection.
Parameters:
Name Type Description
pre string Content to be inserted before the selection
post string Content to be inserted after the selection
Inherited From:
Source:

getClosestScrollableElementContainer() → {HTMLElement}

Get closest scrollable container.
Inherited From:
Source:
Returns:
Closest scrollable container
Type
HTMLElement

getData() → {Mixed}

Get element data.
Inherited From:
Source:
Returns:
Element data
Type
Mixed

getElementDocument() → {HTMLDocument}

Get the DOM document.
Inherited From:
Source:
Returns:
Document object
Type
HTMLDocument

getElementGroup() → {OO.ui.mixin.GroupElement|null}

Get group element is in.
Inherited From:
Source:
Returns:
Group element, null if none
Type
OO.ui.mixin.GroupElement | null

getElementId() → {string}

Ensure that the element has an 'id' attribute, setting it to an unique value if it's missing, and return its value.
Inherited From:
Source:
Returns:
Type
string

getElementWindow() → {Window}

Get the DOM window.
Inherited From:
Source:
Returns:
Window object
Type
Window

getInput() → {OO.ui.TextInputWidget}

Get the combobox's text input widget.
Source:
Returns:
Text input widget
Type
OO.ui.TextInputWidget

(protected) getInputElement(config) → {jQuery}

Get input element. Subclasses of OO.ui.InputWidget use the `config` parameter to produce different elements in different circumstances. The element must have a `value` property (like form elements).
Parameters:
Name Type Description
config Object Configuration options
Inherited From:
Source:
Returns:
Input element
Type
jQuery

getInputId() → {string|null}

Get an ID of a labelable node which is part of this widget, if any, to be used for `
Inherited From:
Source:
Returns:
The ID of the labelable element
Type
string | null

getInputLength() → {number}

Get the length of the text input value. This could differ from the length of #getValue if the value gets filtered
Inherited From:
Source:
Returns:
Input length
Type
number

getMenu() → {OO.ui.MenuSelectWidget}

Get the combobox's menu.
Source:
Returns:
Menu widget
Type
OO.ui.MenuSelectWidget

getRange() → {Object}

Get an object describing the current selection range in a directional manner
Inherited From:
Source:
Returns:
Object containing 'from' and 'to' offsets
Type
Object

(protected) getSaneType(config) → {string|null}

Get sanitized value for 'type' for given config.
Parameters:
Name Type Description
config Object Configuration options
Inherited From:
Source:
Returns:
Type
string | null

getTagName() → {string}

Get the HTML tag name. Override this method to base the result on instance information.
Inherited From:
Source:
Returns:
HTML tag name
Type
string

getValidity() → {jQuery.Promise}

Get the validity of current value. This method returns a promise that resolves if the value is valid and rejects if it isn't. Uses the validation pattern to check for validity.
Inherited From:
Source:
Returns:
A promise that resolves if the value is valid, rejects if not.
Type
jQuery.Promise

getValue() → {string}

Get the value of the input.
Inherited From:
Source:
Returns:
Input value
Type
string

insertContent(content)

Insert new content into the input.
Parameters:
Name Type Description
content string Content to be inserted
Inherited From:
Source:

installParentChangeDetector()

Support function for making #onElementAttach work across browsers. This whole function could be replaced with one line of code using the DOMNodeInsertedIntoDocument event, but it's not supported by Firefox and allegedly deprecated, so we only use it as fallback. Due to MutationObserver performance woes, #onElementAttach is only somewhat reliably called the first time that the element gets attached to the documented.
Inherited From:
Source:

isDisabled() → {boolean}

Check if the widget is disabled.
Inherited From:
Source:
Returns:
Widget is disabled
Type
boolean

isElementAttached() → {boolean}

Check if the element is attached to the DOM
Inherited From:
Source:
Returns:
The element is attached to the DOM
Type
boolean

isReadOnly() → {boolean}

Check if the input is read-only.
Inherited From:
Source:
Returns:
Type
boolean

isRequired() → {boolean}

Check if the input is required.
Inherited From:
Source:
Returns:
Type
boolean

isVisible() → {boolean}

Check if element is visible.
Inherited From:
Source:
Returns:
element is visible
Type
boolean

moveCursorToEnd()

Focus the input and move the cursor to the end.
Inherited From:
Source:

moveCursorToStart()

Focus the input and move the cursor to the start.
Inherited From:
Source:

(protected) restorePreInfuseState(state)

Restore the pre-infusion dynamic state for this widget. This method is called after #$element has been inserted into DOM. The parameter is the return value of #gatherPreInfuseState.
Parameters:
Name Type Description
state Object
Inherited From:
Source:

scrollElementIntoView(configopt) → {jQuery.Promise}

Scroll element into view.
Parameters:
Name Type Attributes Description
config Object <optional>
Configuration options
Inherited From:
Source:
Returns:
Promise which resolves when the scroll is complete
Type
jQuery.Promise

select()

Focus the input and select the entire text.
Inherited From:
Source:

selectRange(from, toopt)

Focus the input and select a specified range within the text.
Parameters:
Name Type Attributes Description
from number Select from offset
to number <optional>
Select to offset, defaults to from
Inherited From:
Source:

setData(data)

Set element data.
Parameters:
Name Type Description
data Mixed Element data
Inherited From:
Source:

setDir(dir)

Set the directionality of the input.
Parameters:
Name Type Description
dir string Text directionality: 'ltr', 'rtl' or 'auto'
Inherited From:
Source:

setDisabled(disabled)

Set the 'disabled' state of the widget. When a widget is disabled, it cannot be used and its appearance is updated to reflect this state.
Parameters:
Name Type Description
disabled boolean Disable widget
Overrides:
Source:

setElementGroup(group)

Set group element is in.
Parameters:
Name Type Description
group OO.ui.mixin.GroupElement | null Group element, null if none
Inherited From:
Source:

setElementId(id)

Set the element has an 'id' attribute.
Parameters:
Name Type Description
id string
Inherited From:
Source:

setInputId(id)

Set the 'id' attribute of the `` element.
Parameters:
Name Type Description
id string
Inherited From:
Source:

setLabelPosition(labelPosition)

Set the position of the inline label relative to that of the value: `‘before’` or `‘after’`.
Parameters:
Name Type Description
labelPosition string Label position, 'before' or 'after'
Inherited From:
Source:

setOptions(options)

Set the options available for this input.
Parameters:
Name Type Description
options Array.<Object> Array of menu options in the format `{ data: …, label: … }`
Source:

setReadOnly(state)

Set the read-only state of the input.
Parameters:
Name Type Description
state boolean Make input read-only
Inherited From:
Source:

setRequired(state)

Set the required state of the input.
Parameters:
Name Type Description
state boolean Make input required
Inherited From:
Source:

setValidation(validate)

Set the validation pattern. The validation pattern is either a regular expression, a function, or the symbolic name of a pattern defined by the class: 'non-empty' (the value cannot be an empty string) or 'integer' (the value must contain only numbers).
Parameters:
Name Type Description
validate RegExp | function | string | null Regular expression, function, or the symbolic name of a pattern (either ‘integer’ or ‘non-empty’) defined by the class.
Inherited From:
Source:

setValidityFlag(isValidopt)

Sets the 'invalid' flag appropriately.
Parameters:
Name Type Attributes Description
isValid boolean <optional>
Optionally override validation result
Inherited From:
Source:

setValue(value)

Set the value of the input.
Parameters:
Name Type Description
value string New value
Inherited From:
Source:
Fires:

simulateLabelClick()

Simulate the behavior of clicking on a label (a HTML `
Inherited From:
Source:

supports(methods) → {boolean}

Check if element supports one or more methods.
Parameters:
Name Type Description
methods string | Array.<string> Method or list of methods to check
Inherited From:
Source:
Returns:
All methods are supported
Type
boolean

toggle(showopt)

Toggle visibility of an element.
Parameters:
Name Type Attributes Description
show boolean <optional>
Make element visible, omit to toggle visibility
Inherited From:
Source:
Fires:
  • event:visible

updateDisabled()

Update the disabled state, in case of changes in parent widget.
Inherited From:
Source:

updatePosition()

Update the position of the inline label. This method is called by #setLabelPosition, and can also be called on its own if something causes the label to be mispositioned.
Inherited From:
Source:

updateThemeClasses()

Update the theme-provided classes.
Inherited From:
Source: