Element: <oj-dialog>

Oracle® JavaScript Extension Toolkit (JET)
5.0.0

E90577-01

QuickNav

Attributes

JET Custom Elements

JET components are implemented as custom HTML elements. In addition to the component attributes documented in this page, JET components also support standard HTML global attributes like id and aria-label.

The JET data binding syntax can be used to define both component and global attributes through the use of dynamically evaluated expressions. All attributes (component and global) support attribute-level binding by prefixing the attribute name with ":" (e.g. :id="[...]"). When using attribute-level binding, all expression values are treated as strings. Additionally, component attributes support property-level binding by using the attribute name directly with no ":" prefix. When using property-level binding, the expressions should evaluate to the types documented by the corresponding attributes. Property-level binding is strongly recommended over attribute-level binding for component attributes.

A detailed description of working with custom HTML elements can be found in: JET Custom Element Usage.


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

Version:
  • 5.0.0
Since:
  • 0.6
Module:
  • ojdialog

JET Dialog Component

Description: Themeable, WAI-ARIA-compliant dialog component. A dialog is a floating window that typically contains a title bar and a content area. The dialog window can be moved by dragging on the title area, and closed with the 'x' icon (by default). Dialogs can also be resized by dragging on edges or corners of the dialog component.

If the content length exceeds the maximum height, a scrollbar will automatically appear.

A bottom button bar and semi-transparent modal overlay layer are common options that can be added.

Styling

Class(es) Description
oj-dialog-header

Class automatically generated on the header slot.

oj-dialog-title

Class used to format the title. Automatically created headers use oj-dialog-title to format the title. For user-defined headers, you may want to use the oj-dialog-title so that the title in your user-defined header is stylistically similar to a default title.

oj-dialog-body

Class automatically generated on the default (body) slot.

oj-dialog-footer

Class automatically generated on the footer slot.

oj-dialog-footer-separator

A separator between the dialog body and the dialog footer can be added by using a second style class ( oj-dialog-footer-separator ) in the footer. So use:

  • oj-dialog-footer oj-dialog-footer-separator
to add a footer separator to the dialog. Note that for themes that have a built-in footer separator (specifically the iOS theme), this class has no effect.

See the demo section for a live example of the footer separator.

oj-progress-bar-embedded

Optional markup. Used to format a progress bar embedded in the dialog header.

oj-focus-highlight Under normal circumstances this class is applied automatically. It is documented here for the rare cases that an app developer needs per-instance control.

The oj-focus-highlight class applies focus styling that may not be desirable when the focus results from pointer interaction (touch or mouse), but which is needed for accessibility when the focus occurs by a non-pointer mechanism, for example keyboard or initial page load.

The application-level behavior for this component is controlled in the theme by the $focusHighlightPolicy SASS variable; however, note that this same variable controls the focus highlight policy of many components and patterns. The values for the variable are:

  • nonPointer: oj-focus-highlight is applied only when focus is not the result of pointer interaction. Most themes default to this value.
  • all: oj-focus-highlight is applied regardless of the focus mechanism.
  • none: oj-focus-highlight is never applied. This behavior is not accessible, and is intended for use when the application wishes to use its own event listener to precisely control when the class is applied (see below). The application must ensure the accessibility of the result.

To change the behavior on a per-instance basis, the application can set the SASS variable as desired and then use event listeners to toggle this class as needed.

Note that the dialog component wraps additional divs around the user's content and also performs other DOM manipulations. Thus, the user should be careful if they wish to engage in advanced coding approaches. In general, it is best to target DOM elements by id or class name (e.g., developers should not rely on relative positioning of dialog DOM elements).

Focus

Upon opening a dialog, focus is automatically moved to the first item that matches the following:

  1. The first element within the dialog with the autofocus attribute
  2. The first :tabbable element within the dialog body
  3. The first :tabbable element within the dialog footer
  4. The dialog's close button
  5. The dialog itself

While open, the dialog widget ensures that tabbing cycles focus between elements within the dialog itself, not elements outside of it. Modal dialogs additionally prevent mouse users from clicking on elements outside of the dialog.

Upon closing a dialog, focus is automatically returned to the element that had focus when the dialog was opened.

See also the oj-focus-highlight discussion.

Touch End User Information

Target Gesture Action
Dialog Close Icon Tap Close the dialog.

Keyboard End User Information

The JET Dialog can be closed with keyboard actions:

Target Key Action
Dialog Esc Close the dialog.
Dialog Close Icon Enter or Space Close the dialog.

Sizing

Dialog dimensions, including height, width, min-width, max-width, min-height and max-height are defined with css variables. The default dialog dimensions are the following:

  • height: auto
  • width: 300px
  • min-width: 200px
In most cases, you will want to use the default height:auto, since this will automatically adjust the height based on the content. Users can change the dialog dimensions using style attributes:

<oj-dialog id="wideDialog" title="Wide Dialog" style="width: 400px; min-width: 100px; max-width 500px;">
   <div slot="body">
      <p> Dialog Text
   </div>
</oj-dialog>

Accessibility

role

By default, the role will be set to dialog. This can be observed by inspecting the DOM:

 <div class="ojdialog ..." role="dialog">
This can be changed using the role attribute. WAI-ARIA recommends that role="dialog" be used if the dialog expects input (such as text input), otherwise, use the role attribute to assign role="alertdialog".

aria-labelledby

For both default and user-defined headers, the dialog component takes care of aria-labelledby for you. The aria-labelledby attribute is generated automatically (and set to the id of the header's title). For user-defined headers, the title div is identified by the div that has the oj-dialog-title class. Note that user-defined headers must have a title div (in order to meet accesibility requirements).

See also the oj-focus-highlight discussion.

Reparenting

When dialogs are open, they will be reparented into a common container in the document body and reparented back when closed. Within this container in the body, dialogs will always be top rooted but other types of dialogs used within an open dialog will be reparented within the dialog's layer. The dialog's layer defines its z-index weight "stacking context" and marked by the "oj-dialog-layer" style. The goal of this design is to maintain as much of the page author's document structure while avoiding most of the clipping and positioning issues of a completely inline design. Dialogs are assigned the same z-index values The layering between dialog peers reflect the opening order. In addition, the dialog that has active focus will be assigned a greater z-index by way of the "oj-focus-within" pseudo selector applied with "oj-dialog-layer" selector. The page author has control over z-index weights by way of the "oj-dialog-layer" selector.

There are known caveats with this design. However, these scenarios are considered "bad use" based on our JET dialog/popup strategy.

  1. Events raised within the dialog will not bubble up to the dialog's original ancestors. Instead, listeners for menu events should be applied to either the dialog's root element, or the document.
  2. Likewise, developers should not use CSS descendant selectors, or similar logic, that assumes that the dialog will remain a child of its original parent.
  3. Dialogs containing iframes are problematic. The iframe elements "may" fire a HTTP GET request for its src attribute each time the iframe is reparented in the document.
  4. In some browsers, reparenting a dialog that contains elements having overflow, will cause these overflow elements to reset their scrollTop.

Reading direction

Setting the reading direction (LTR or RTL) is supported by setting the "dir" attribute on the <html> element of the page. As with any JET component, in the unusual case that the reading direction is changed post-init, the dialog must be refresh()ed, or the page must be reloaded.

Pseudo-selectors

The :oj-dialog pseudo-selector can be used in jQuery expressions to select JET Dialogs. For example:

$( ":oj-dialog" ) // selects all JET Dialogs on the page
$myEventTarget.closest( ":oj-dialog" ) // selects the closest ancestor that is a JET Dialog

Additional Examples

The following defines a basic dialog, with an ok button in the footer:


<oj-dialog id="dialogWithFooter" title="Dialog with Footer" style="width: 400px; min-width: 100px; max-width 500px;">
   <div slot="body">
      <p> Dialog Text
   </div>
   <div slot="footer">
      <oj-button id="okButton"> OK </oj-button>
   </div>
</oj-dialog>

Note that you will need to define your own event handlers for the ok and close buttons (see the demos for examples of this).

A dialog with user-defined header is shown next. Arbitrary header content can be defined using a user-defined header.


<oj-dialog id="dialog" title="Dialog Title">
   <div slot="header">
      <span id="dialog-title-id" class="oj-dialog-title"> User Defined Header</span>
   </div>
   <div slot="body">
      <p> Dialog Text
   </div>
</oj-dialog>

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

The default slot is the dialog's body. The <oj-dialog> element accepts DOM nodes as children for the default slot. The default slot can also be named with "body". For styling, the default body slot will be rendered with the oj-dialog-body class.

Since:
  • 4.0.0
Examples

Initialize the Dialog with body content:

<oj-dialog>
  <div>Dialog Content</div>
</oj-dialog>

Initialize the Dialog with body content, explicitly naming the body slot:

<oj-dialog>
  <div slot="body">Dialog Content</div>
</oj-dialog>

contextMenu

The contextMenu slot is set on the oj-menu within this element. This is used to designate the JET Menu that this component should launch as a context menu on right-click, Shift-F10, Press & Hold, or component-specific gesture. If specified, the browser's native context menu will be replaced by the JET Menu specified in this slot.

The application can register a listener for the Menu's ojBeforeOpen event. The listener can cancel the launch via event.preventDefault(), or it can customize the menu contents by editing the menu DOM directly, and then calling refresh() on the Menu.

To help determine whether it's appropriate to cancel the launch or customize the menu, the ojBeforeOpen listener can use component API's to determine which table cell, chart item, etc., is the target of the context menu. See the JSDoc and demos of the individual components for details.

Keep in mind that any such logic must work whether the context menu was launched via right-click, Shift-F10, Press & Hold, or component-specific touch gesture.

Example

Initialize the component with a context menu:

<oj-some-element>
    <-- use the contextMenu slot to designate this as the context menu for this component -->
    <oj-menu slot="contextMenu" style="display:none" aria-label="Some element's context menu">
...
    </oj-menu>
</oj-some-element>

The footer slot is for the dialog's footer area. The <oj-dialog> element accepts DOM nodes as children with the footer slot. For styling, the footer body slot will be rendered with the oj-dialog-footer class.

Since:
  • 4.0.0
Example

Initialize the Dialog with body and footer content:

<oj-dialog>
  <div>Dialog Content</div>
  <div slot='footer'>Footer Content</div>
</oj-dialog>

The header slot is for the dialog's header area. The <oj-dialog> element accepts DOM nodes as children with the header slot. For styling, the header slot will be rendered with the oj-dialog-header class.

If a header slot is not specified by the user, a header will automatically be created. The automatically generated header will contain a close button, and the header title will be set to the dialog title.
Since:
  • 4.0.0
Example

Initialize the Dialog with header and body content:

<oj-dialog>
  <div slot='header'>Header Content</div>
  <div>Dialog Content</div>
</oj-dialog>

Attributes

cancel-behavior :string

Specifies the cancel behavior of the dialog. The following are valid values:
  • "icon" - (the default) (a) a close icon will automatically be created, and (b) the dialog will close when it has focus and user presses the escape (ESC) key.
  • "none" - no actions will be associated with the escape key.
  • "escape" - the dialog will close when it has focus and user presses the escape (ESC) key. A close icon will not automatically be created.
Note that the cancelBehavior applies to both automatic and user-defined headers. So by default, a user-defined header will have a system generated close icon.
Default Value:
  • "icon"
Names
Item Name
Property cancelBehavior
Property change event cancelBehaviorChanged
Property change listener attribute (must be of type function) on-cancel-behavior-changed
Examples

Initialize the dialog to disable the default cancelBehavior

<oj-dialog cancel-behavior="none" ></oj-dialog>

Get or set the cancelBehavior property, after initialization:

// getter
var cancelBehavior = myDialog.cancelBehavior;

// setter
myDialog.cancelBehavior = "none";

Set the default in the theme (SCSS) :

$dialogCancelBehaviorOptionDefault: none !default;

drag-affordance :string

Specifies the drag affordance. If set to "title-bar" (the default) the dialog will be draggable by the title bar. If "none", the dialog will not be draggable.
Default Value:
  • "title-bar"
Names
Item Name
Property dragAffordance
Property change event dragAffordanceChanged
Property change listener attribute (must be of type function) on-drag-affordance-changed
Examples

Initialize the dialog to disable dragging dragAffordance

<oj-dialog drag-affordance="none" ></oj-dialog>

Get or set the dragAffordance property, after initialization:

// getter
var dragAffordance = myDialog.dragAffordance;

// setter
myDialog.dragAffordance = "none";

initial-visibility :string

Set the initial visibility of the dialog. If set to "show", the dialog will automatically open upon initialization. If "hide", the dialog will stay hidden until the open() method is called.

Default Value:
  • "hide"
Names
Item Name
Property initialVisibility
Property change event initialVisibilityChanged
Property change listener attribute (must be of type function) on-initial-visibility-changed
Examples

Initialize the dialog with the initialVisibility property:

<oj-dialog initial-visibility="show" ></oj-dialog>

Get or set the initialVisibility property, after initialization:

// getter
var initialVisibility = myDialog.initialVisibility;

// setter
myDialog.initialVisibility = "show";

modality :string

The modality of the dialog. Valid values are:
  • "modal" - (the default) The dialog is modal. Interactions with other page elements are disabled. Modal dialogs overlay other page elements.
  • "modeless" - defines a modeless dialog.
Default Value:
  • "modal"
Names
Item Name
Property modality
Property change event modalityChanged
Property change listener attribute (must be of type function) on-modality-changed
Examples

Initialize the dialog to a specific modality modality

<oj-dialog modality="modeless" ></oj-dialog>

Get or set the modality property, after initialization:

// getter
var modality = myDialog.modality;

// setter
myDialog.modality = "modeless";

position :oj.ojDialog.Position

Position object is used to establish the location the dialog will appear relative to another element. oj.ojDialog.Position defines "my" alignment "at" the alignment "of" some other thing which can be "offset" by so many pixels.

The "my" and "at" properties defines aligment points relative to the dialog and other element. The "my" property represents the dialog's alignment where the "at" property represents the other element that can be identified by "of". The values of these properties describe horizontal and vertical alignments.

Deprecated v3.0.0 jQuery UI position syntax; Use of a percent unit with "my" or "at" is not supported.
Default Value:
  • {"my":{"vertical" :"center", "horizontal": "center"}, "at": {"vertical": "center", "horizontal": "center"}, "of": "window", "collision": "fit", "offset": {"x": 0, "y": "0"}}
Names
Item Name
Property position
Property change event positionChanged
Property change listener attribute (must be of type function) on-position-changed
Examples

Initialize the dialog with position property specified:

<oj-dialog position.my.horizontal="left"
          position.my.vertical="top"
          position.at.horizontal="right"
          position.at.vertical="top" ></oj-dialog>

Get or set the position property, after initialization:

// getter
var position = myDialog.position;

// setter
myDialog.position =
   {"my": {"horizontal": "start", "vertical": "bottom"},
    "at": {"horizontal": "end", "vertical": "top" },
    "offset": {"x": 0, "y":5}};

position.at :Object

Defines which position on the target element ("of") to align the positioned element against.
Names
Item Name
Property position.at

position.at.horizontal :string

Supported Values:
Name Type Description
"center" string
"end" string evaluates to "right" in LTR mode and "left" in RTL mode.
"left" string
"right" string
"start" string evaluates to "left" in LTR mode and "right" in RTL mode.
Names
Item Name
Property position.at.horizontal

position.at.vertical :string

Supported Values:
Name Type
"bottom" string
"center" string
"top" string
Names
Item Name
Property position.at.vertical

position.collision :string

Rule for alternate alignment.
Supported Values:
Name Type Description
"fit" string shift the element away from the edge of the window.
"flip" string the element to the opposite side of the target and the collision detection is run again to see if it will fit. Whichever side allows more of the element to be visible will be used.
"flipfit" string first applies the flip logic, placing the element on whichever side allows more of the element to be visible. Then the fit logic is applied to ensure as much of the element is visible as possible.
"none" string no collision detection.
Names
Item Name
Property position.collision

position.my :Object

Defines which edge on the dialog to align with the target ("of") element.
Names
Item Name
Property position.my

position.my.horizontal :string

Supported Values:
Name Type Description
"center" string
"end" string evaluates to "right" in LTR mode and "left" in RTL mode.
"left" string
"right" string
"start" string evaluates to "left" in LTR mode and "right" in RTL mode.
Names
Item Name
Property position.my.horizontal

position.my.vertical :string

Supported Values:
Name Type
"bottom" string
"center" string
"top" string
Names
Item Name
Property position.my.vertical

position.of :string|Object

Which element to position the dialog against. If the value is a string, it should be a selector or the literal string value of window. Otherwise, a point of x,y. When a point is used, the values are relative to the whole document. Page horizontal and vertical scroll offsets need to be factored into this point - see UIEvent pageX, pageY.
Names
Item Name
Property position.of
Example

Finding the point for an svg element:

var rect = svgDom.getBoundingClientRect();
var position = {of:{x:rect.left + window.pageXOffset, y:rect.top + window.pageYOffset}};

position.offset :Object

Defines a point offset in pixels from the ("my") alignment.
Names
Item Name
Property position.offset

position.offset.x :number

Horizontal aligment offset.
Names
Item Name
Property position.offset.x

position.offset.y :number

Vertical alignment offset.
Names
Item Name
Property position.offset.y

resize-behavior :string

The resizeBehavior of the dialog. "resizable" (default) makes the dialog resizable. "none" disables dialog resizability.
Default Value:
  • "resizable"
Names
Item Name
Property resizeBehavior
Property change event resizeBehaviorChanged
Property change listener attribute (must be of type function) on-resize-behavior-changed
Examples

Initialize the dialog to a specific resizeBehavior resizeBehavior

<oj-dialog resize-behavior="none" ></oj-dialog>

Get or set the resizeBehavior property, after initialization:

// getter
var resizeBehavior = myDialog.resizeBehavior;

// setter
myDialog.resizeBehavior = "none";

Set the default in the theme (SCSS) :

$dialogResizeBehaviorOptionDefault: none !default;

role :string

The WAI-ARIA role of the dialog. By default, role="dialog" is added to the generated HTML markup that surrounds the dialog. When used as an alert dialog, the user should set role to "alertdialog".
Default Value:
  • "dialog"
Names
Item Name
Property role
Property change event roleChanged
Property change listener attribute (must be of type function) on-role-changed
Examples

Initialize the dialog with the role property specified:

<oj-dialog role="alertdialog" ></oj-dialog>

Get or set the role property, after initialization:

// getter
var role = myDialog.role;

// setter
myDialog.role = "alertdialog";

translations :Object|null

A collection of translated resources from the translation bundle, or null if this component has no resources. Resources may be accessed and overridden individually or collectively, as seen in the examples.

If the component does not contain any translatable resource, the default value of this attribute will be null. If not, an object containing all resources relevant to the component.

If this component has translations, their documentation immediately follows this doc entry.

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

Initialize the component, overriding some translated resources and leaving the others intact:

<!-- Using dot notation -->
<oj-some-element translations.some-key='some value' translations.some-other-key='some other value'></oj-some-element>

<!-- Using JSON notation -->
<oj-some-element translations='{"someKey":"some value", "someOtherKey":"some other value"}'></oj-some-element>

Get or set the translations property after initialization:

// Get one
var value = myComponent.translations.someKey;

// Set one, leaving the others intact. Always use the setProperty API for 
// subproperties rather than setting a subproperty directly.
myComponent.setProperty('translations.someKey', 'some value');

// Get all
var values = myComponent.translations;

// Set all.  Must list every resource key, as those not listed are lost.
myComponent.translations = {
    someKey: 'some value',
    someOtherKey: 'some other value'
};

(nullable) translations.label-close-icon :string

Label for the dialog close button.

See the translations attribute for usage examples.

Default Value:
  • "Close"
Since:
  • 3.0
Names
Item Name
Property translations.labelCloseIcon

Events

ojAnimateEnd

Triggered when a default animation has ended, such as when the component is being opened/closed or a child item is being added/removed. This event is not triggered if the application has called preventDefault on the animateStart event.
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Argument Description
element Element <not nullable>
target of animation
action "open" | "close" The action that is ending the animation. The number of actions can vary from component to component. Suggested values are:
  • "open" - when a dialog component is opened
  • "close" - when a dialog component is closed
Examples

Bind an event listener to the onOjAnimateEnd property to listen for the "close" ending animation:

myDialog.onOjAnimateEnd = function( event )
  {
    // verify that the component firing the event is a component of interest and action
     is close
    if (event.detail.action == "close") {}
  };

The default open and close animations are controlled via the theme (SCSS) :

$dialogOpenAnimation: (effect: "zoomIn", fade: true)  !default;
$dialogCloseAnimation: (effect: "zoomOut", fade: true)  !default;

Specify an ojAnimateEnd listener via the DOM attribute:

<oj-dialog on-oj-animate-end='[[listener]]'></oj-dialog>

Specify an ojAnimateEnd listener via the JavaScript property:

myDialog.onOjAnimateEnd = listener;

Add an ojAnimateEnd listener via the addEventListener API:

myDialog.addEventListener('ojAnimateEnd', listener);

ojAnimateStart

Triggered when a default animation is about to start, such as when the component is being opened/closed or a child item is being added/removed. The default animation can be cancelled by calling event.preventDefault.
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Argument Description
action "open" | "close" The action that is starting the animation. The number of actions can vary from component to component. Suggested values are:
  • "open" - when a dialog component is opened
  • "close" - when a dialog component is closed
element Element <not nullable>
target of animation
endCallback function():void <not nullable>
If the event listener calls event.preventDefault to cancel the default animation, It must call the endCallback function when it finishes its own animation handling and any custom animation has ended.
Examples

Bind an event listener to the onOjAnimateStart property to override the default "close" animation:

myDialog.onOjAnimateStart = function( event )
  {
    // verify that the component firing the event is a component of interest and action
     is close
    if (event.detail.action == "close") {
      event.preventDefault();
      oj.AnimationUtils.slideOut(event.detail.element).then(event.detail.endCallback);
  };

The default open and close animations are controlled via the theme (SCSS) :

$dialogOpenAnimation: ((effect: "zoomIn"), "fadeIn")  !default;
$dialogCloseAnimation: ((effect: "zoomOut", persist: "all"), "fadeOut")  !default;

Specify an ojAnimateStart listener via the DOM attribute:

<oj-dialog on-oj-animate-start='[[listener]]'></oj-dialog>

Specify an ojAnimateStart listener via the JavaScript property:

myDialog.onOjAnimateStart = listener;

Add an ojAnimateStart listener via the addEventListener API:

myDialog.addEventListener('ojAnimateStart', listener);

ojBeforeClose

Triggered before the dialog is dismissed via the close() method. The close can be cancelled by calling event.preventDefault().
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Description
event Event a custom event
Examples

Specify an ojBeforeClose listener via the DOM attribute:

<oj-dialog on-oj-before-close='[[listener]]'></oj-dialog>

Specify an ojBeforeClose listener via the JavaScript property:

myDialog.onOjBeforeClose = listener;

Add an ojBeforeClose listener via the addEventListener API:

myDialog.addEventListener('ojBeforeClose', listener);

ojBeforeOpen

Triggered before the dialog is launched via the open() method. The open can be cancelled by calling event.preventDefault().
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Description
event Event a custom event
Examples

Specify an ojBeforeOpen listener via the DOM attribute:

<oj-dialog on-oj-before-open='[[listener]]'></oj-dialog>

Specify an ojBeforeOpen listener via the JavaScript property:

myDialog.onOjBeforeOpen = listener;

Add an ojBeforeOpen listener via the addEventListener API:

myDialog.addEventListener('ojBeforeOpen', listener);

ojClose

Triggered after the dialog is dismissed via the close() method.
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Description
event Event a custom event
Examples

Specify an ojClose listener via the DOM attribute:

<oj-dialog on-oj-close='[[listener]]'></oj-dialog>

Specify an ojClose listener via the JavaScript property:

myDialog.onOjClose = listener;

Add an ojClose listener via the addEventListener API:

myDialog.addEventListener('ojClose', listener);

ojFocus

Triggered after focus has been transfered to the dialog.
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Description
event Event a custom event
Examples

Specify an ojFocus listener via the DOM attribute:

<oj-dialog on-oj-focus='[[listener]]'></oj-dialog>

Specify an ojFocus listener via the JavaScript property:

myDialog.onOjFocus = listener;

Add an ojFocus listener via the addEventListener API:

myDialog.addEventListener('ojFocus', listener);

ojOpen

Triggered after the dialog is launched via the open() method.
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Description
event Event a custom event
Examples

Specify an ojOpen listener via the DOM attribute:

<oj-dialog on-oj-open='[[listener]]'></oj-dialog>

Specify an ojOpen listener via the JavaScript property:

myDialog.onOjOpen = listener;

Add an ojOpen listener via the addEventListener API:

myDialog.addEventListener('ojOpen', listener);

ojResize

Triggered when the dialog is being resized.
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Description
event Event a custom event
Examples

Specify an ojResize listener via the DOM attribute:

<oj-dialog on-oj-resize='[[listener]]'></oj-dialog>

Specify an ojResize listener via the JavaScript property:

myDialog.onOjResize = listener;

Add an ojResize listener via the addEventListener API:

myDialog.addEventListener('ojResize', listener);

ojResizeStart

Triggered when the user starts resizing the dialog.
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Description
event Event a custom event
  • event
    Type: Event
  • ui
    Type: Object
    • originalPosition
      Type: Object
      The CSS position of the dialog prior to being resized.
    • position
      Type: Object
      The current CSS position of the dialog.
    • originalSize
      Type: Object
      The size of the dialog prior to being resized.
    • size
      Type: Object
      The current size of the dialog.
Examples

Specify an ojResizeStart listener via the DOM attribute:

<oj-dialog on-oj-resize-start='[[listener]]'></oj-dialog>

Specify an ojResizeStart listener via the JavaScript property:

myDialog.onOjResizeStart = listener;

Add an ojResizeStart listener via the addEventListener API:

myDialog.addEventListener('ojResizeStart', listener);

ojResizeStop

Triggered when the user stops resizing the dialog.
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Description
event Event a custom event
  • event
    Type: Event
  • ui
    Type: Object
    • originalPosition
      Type: Object
      The CSS position of the dialog prior to being resized.
    • position
      Type: Object
      The current CSS position of the dialog.
    • originalSize
      Type: Object
      The size of the dialog prior to being resized.
    • size
      Type: Object
      The current size of the dialog.
Examples

Specify an ojResizeStop listener via the DOM attribute:

<oj-dialog on-oj-resize-stop='[[listener]]'></oj-dialog>

Specify an ojResizeStop listener via the JavaScript property:

myDialog.onOjResizeStop = listener;

Add an ojResizeStop listener via the addEventListener API:

myDialog.addEventListener('ojResizeStop', listener);

Methods

close() → {void}

Closes the dialog.
Fires:
Returns:
Type
void
Example

Invoke the close method:

myDialog.close();

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.
Since:
  • 4.0.0
Returns:
Type
*
Example

Get a single subproperty of a complex property:

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

isOpen() → {boolean}

Returns true if the dialog is currently open. This method does not accept any arguments.

The "open" state reflects the period of time the dialog is visible, including open and close animations.
Returns:
true if the dialog is open.
Type
boolean
Example

Invoke the isOpen method:

var isOpen = myDialog.isOpen();

open() → {void}

Opens the dialog.
Fires:
Returns:
Type
void
Example

Invoke the open method:

var open = myDialog.open();

refresh() → {void}

Refresh the dialog. Typically used after dynamic content is added to a dialog.
Returns:
Type
void
Example

Invoke the refresh method:

myDialog.refresh();

setProperties(properties) → {void}

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

Set a batch of properties:

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

setProperty(property, value) → {void}

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.
Since:
  • 4.0.0
Returns:
Type
void
Example

Set a single subproperty of a complex property:

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

Type Definitions

Position

Properties:
Name Type Argument Description
my oj.ojDialog.PositionAlign <optional>
Defines which edge on the popup to align with the target ("of") element.
at oj.ojDialog.PositionAlign <optional>
Defines which position on the target element ("of") to align the positioned element against.
offset oj.ojDialog.PositionPoint <optional>
Defines a point offset in pixels from the ("my") alignment.
of string | oj.ojDialog.PositionPoint <optional>
Which element to position the popup against. If the value is a string, it should be a selector or the literal string value of window. Otherwise, a point of x,y. When a point is used, the values are relative to the whole document. Page horizontal and vertical scroll offsets need to be factored into this point - see UIEvent pageX, pageY.
collision "flip" | "fit" | "flipfit" | "none" <optional>
Rule for alternate alignment.

  • "flip" the element to the opposite side of the target and the collision detection is run again to see if it will fit. Whichever side allows more of the element to be visible will be used.
  • "fit" shift the element away from the edge of the window.
  • "flipfit" first applies the flip logic, placing the element on whichever side allows more of the element to be visible. Then the fit logic is applied to ensure as much of the element is visible as possible.
  • "none" no collision detection.

PositionAlign

Properties:
Name Type Argument Description
vertical "top" | "bottom" | "center" <optional>
Vertical alignment.
horizontal "start" | "end" | "left" | "center" | "bottom" <optional>
Horizontal alignment.

  • "start" evaluates to "left" in LTR mode and "right" in RTL mode.
  • "end" evaluates to "right" in LTR mode and "left" in RTL mode.

PositionPoint

Properties:
Name Type Argument Description
x number <optional>
Horizontal aligment offset.
y number <optional>
Vertical alignment offset.