Element: <oj-option>

Oracle® JavaScript Extension Toolkit (JET)
4.2.0

E91398-01

QuickNav

Attributes

PREVIEW: This is a preview API. Preview APIs are production quality, but can be changed on a major version without a deprecation path.

Version:
  • 4.2.0
Since:
  • 4.0.0

JET Custom Elements

JET components are implemented as custom HTML elements. A detailed description of working with these elements can be found in: JET Custom Element Usage.

JET Option

The oj-option element is used to declare values for JET elements that display list of values. It's supported by the following elements:

  • oj-buttonset-one
  • oj-buttonset-many
  • oj-checkboxset
  • oj-combobox-one
  • oj-combobox-many
  • oj-menu
  • oj-radioset
  • oj-select-one
  • oj-select-many

For example:


<oj-select-one>
  <oj-option value="option 1">option 1</oj-option>
  <oj-option value="option 2">option 2</oj-option>
  <oj-option value="option 3">option 3</oj-option>
  <oj-option value="option 4">option 4</oj-option>
</oj-select-one> 

Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.

Slots

JET elements can have up to two types of child content:

  • Any child element with a slot attribute will be moved into that named slot, e.g. <span slot='startIcon'>...</span>. All supported named slots are documented below. Child elements with unsupported named slots will be removed from the DOM.
  • Any child element lacking a slot attribute will be moved to the default slot, also known as a regular child. This is documented under the "Default" heading below.

Default

Child content for oj-option. This is normally the text node that displays for oj-option.

Example

Initialize the oj-option with child content specified:

<oj-option>
  Option label
</oj-option>

endIcon

Named slot for the oj-option's end icon.

Example

Initialize the oj-option with the endIcon slot specified:

<oj-option>
  <span slot='endIcon'><img src='end.png' alt='End'></span>
</oj-option>

startIcon

Named slot for the oj-option's start icon.

Example

Initialize the oj-option with the startIcon slot specified:

<oj-option>
  <span slot='startIcon'><img src='start.png' alt='Start'></span>
</oj-option>

Attributes

disabled :boolean

Disables the oj-option if set to true.

Default Value:
  • false
Names
Item Name
Property disabled
Property change event disabledChanged
Property change listener attribute (must be of type function) on-disabled-changed
Examples

Initialize the oj-option with the disabled attribute specified:

<oj-option disabled="[[isDisabled]]" value="option1">Option1</oj-option>

Get or set the disabled property after initialization:

// getter
var disabledValue = myOption.disabled;

// setter
myOption.disabled = true;

value :*

Specifies the oj-option's value. The value is associated with the oj-option element whose display value may be different.

Names
Item Name
Property value
Property change event valueChanged
Property change listener attribute (must be of type function) on-value-changed
Examples

Initialize the oj-option with the value attribute specified:

<oj-option value="option1">Option1</oj-option>

Get or set the value property after initialization:

// getter
var optionValue = myOption.value;

// setter
myOption.value = 'option1';

Methods

getProperty(property) → {*}

Retrieves a value for a property or a single subproperty for complex properties.
Parameters:
Name Type Description
property string The property name to get. Supports dot notation for subproperty access.
Returns:
Type
*
Example

Get a single subproperty of a complex property:

var subpropValue = myComponent.getProperty('complexProperty.subProperty1.subProperty2');

refresh()

Refreshes the visual state of the component.

setProperties(properties)

Performs a batch set of properties.
Parameters:
Name Type Description
properties Object An object containing the property and value pairs to set.
Example

Set a batch of properties:

myComponent.setProperties({"prop1": "value1", "prop2.subprop": "value2", "prop3": "value3"});

setProperty(property, value)

Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a [property]Changed event.
Parameters:
Name Type Description
property string The property name to set. Supports dot notation for subproperty access.
value * The new value to set the property to.
Example

Set a single subproperty of a complex property:

myComponent.setProperty('complexProperty.subProperty1.subProperty2', "someValue");