Element: <oj-module>

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:
  • 4.2.0
Module:
  • ojmodule-element

JET Module

The oj-module custom element is used for binding a view and a corresponding view model to an element to provide content replacement within a particular region of the page. In case of a single page application the element config attribute defines navigation within a region.


<oj-module config='[[moduleConfig]]' animation='[[moduleAnimation]]'>
</oj-module>

View Model Lifecycle

If a ViewModel is provided as a part of configuration for the oj-module element, the following optional callback methods can be defined on its ViewModel and will be called at each stage of the component's lifecycle.

connected()

The optional method may be implemented on the ViewModel and will be invoked after the View is inserted into the DOM.

This method might be called multiple times - after the View is created and inserted into the DOM, after the View is reconnected after being disconnected and after a parent element, oj-module, with attached View is reconnected to the DOM.

transitionCompleted()

This optional method may be implemented on ViewModel and invoked after transition to the new View is complete. That includes any possible animation between the old and the new View.

disconnected()

This optional method maybe implemented on the ViewModel and will be invoked when the View is disconnected from the DOM.

This method might be called multiple times - after the View is disconnected from the DOM and after a parent element,oj-module, with attached View is disconnected from the DOM.

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.

Attributes

animation :Object

Instance of the oj.ModuleElementAnimation duck-typing interface that will manage animation effects during View transitions.
Default Value:
  • null
Names
Item Name
Property animation
Property change event animationChanged
Property change listener attribute (must be of type function) on-animation-changed

config :Object

Configuration object that defines a view and a corresponding view model responsible the markup section under oj-module. An application can also specify a clean up mode for the view as a part of the configuration object. See details for each attribute.
Default Value:
  • null
Names
Item Name
Property config
Property change event configChanged
Property change listener attribute (must be of type function) on-config-changed
Examples

Initialize the ojModule element with the config attribute:

<oj-module config='[[moduleConfig]]'></oj-module>

Get or set the accept property after initialization:

// getter
var config = myModule.config;

// setter
myModule.config = {'view':view,'viewModel':viewModel}; // where view is an Array of DOM nodes and viewModel is a model object for the view

config.cleanup-mode :string

Defines the clean up mode for the view.
Supported Values:
Name Type Description
"none" string Use the setting to preserve the view, e.g. if the view and view model will be stored in external cache.
"onDisconnect" string The View nodes will be destroyed on disconnect.
Default Value:
  • "onDisconnect"
Names
Item Name
Property config.cleanupMode

config.view :Array.<Node>

Defines the view for the ojModule.

Note that oj-module will not be cloning the node array before using it as the module's View and applying bindings to it. If the application needs to have an access to the original node array, it should be setting the 'view' property to a cloned copy.

Default Value:
  • null
Names
Item Name
Property config.view

config.view-model :Object

Defines model for the view.

The following optional lifecycle methods can be defined on the ViewModel object and will be called at the corresponding lifecycle stage. See View Model Lifecycle section

Default Value:
  • null
Names
Item Name
Property config.viewModel

Events

ojTransitionEnd

Triggered after transition to the new View is complete. That includes any possible animation between the old and the new View.
Properties:

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

Name Type Description
viewModel Object ViewModel for the new View.
Examples

Specify an ojTransitionEnd listener via the DOM attribute:

<oj-module on-oj-transition-end='[[listener]]'></oj-module>

Specify an ojTransitionEnd listener via the JavaScript property:

myModule.onOjTransitionEnd = listener;

Add an ojTransitionEnd listener via the addEventListener API:

myModule.addEventListener('ojTransitionEnd', listener);

ojTransitionStart

Triggered before transition to the new View is started - before View is inserted into the DOM.
Properties:

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

Name Type Description
viewModel Object ViewModel for the new View.
Examples

Specify an ojTransitionStart listener via the DOM attribute:

<oj-module on-oj-transition-start='[[listener]]'></oj-module>

Specify an ojTransitionStart listener via the JavaScript property:

myModule.onOjTransitionStart = listener;

Add an ojTransitionStart listener via the addEventListener API:

myModule.addEventListener('ojTransitionStart', listener);

ojViewConnected

Triggered after the View is inserted into the DOM.
Properties:

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

Name Type Description
viewModel Object ViewModel for the View being attached to the DOM.
Examples

Specify an ojViewConnected listener via the DOM attribute:

<oj-module on-oj-view-connected='[[listener]]'></oj-module>

Specify an ojViewConnected listener via the JavaScript property:

myModule.onOjViewConnected = listener;

Add an ojViewConnected listener via the addEventListener API:

myModule.addEventListener('ojViewConnected', listener);

ojViewDisconnected

Triggered after the View is removed from the DOM
Properties:

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

Name Type Description
viewModel Object An array of DOM nodes that represent the disconnected View. The application can use the nodes to store them in cache.
view Array.<Node> ViewModel for the new View.
Examples

Specify an ojViewDisconnected listener via the DOM attribute:

<oj-module on-oj-view-disconnected='[[listener]]'></oj-module>

Specify an ojViewDisconnected listener via the JavaScript property:

myModule.onOjViewDisconnected = listener;

Add an ojViewDisconnected listener via the addEventListener API:

myModule.addEventListener('ojViewDisconnected', listener);