Class: ojNavigationList

Oracle® JavaScript Extension Toolkit (JET)
1.2.0

E65435-01

QuickNav

Options


Binding Attributes
Sub-ID's

oj. ojNavigationList extends oj.baseComponent

Version:
  • 1.2.0
Since:
  • 1.1.0

Description: The JET Navigation List enhances a HTML list element into a themable, WAI-ARIA compliant, mobile friendly component with advance interactive features.

The JET Navigation List gets its data in following ways.

  • Using table datasource. This is typically used in case of flat list.There are several types of TableDataSource that are available out of the box like oj.ArrayTableDataSource,oj.CollectionTableDataSource.NOTE: oj.PagingTableDataSource is not supported by navigation list. For large amount of data, It is recommended to use hierarhcial navigation list with tree data source.
  • Using TreeDataSource. This is typically used to display hierarchical navigation list. There are several types of TreeDataSource that are available out of the box like oj.JsonTreeDataSource, oj.CollectionTreeDataSource
  • Using static content . The structure of the content can be either flat or hierarhical.

Example of flat static content


<div id="navigationlist">
 <ul>
  <li><a href="#">Item 1</a></li>
  <li><a href="#">Item 2</a></li>
  <li><a href="#">Item 3</a></li>
 </ul>
</div>

Example of hierarchical static content


<div id="navigationlist">
 <ul >
  <li><a href="#">Item 1</a></li>
  <li><a href="#">Item 2</a></li>
  <li><a href="#">Item 3</a>
    <ul>
      <li><a href="#">Item 3-1</a></li>
      <li><a href="#">Item 3-2</a></li>
      <li><a href="#">Item 3-3</a></li>
      <li><a href="#">Item 3-4</a></li>
      <li><a href="#">Item 3-5</a></li>
    </ul>
  </li>
  <li><a href="#">Item 4</a></li>
  <li><a href="#">Item 5</a></li>
 </ul>
</div>

JSON Tree Node Format


Each node object typically have an attr property. This attr value will be provided as itemContext.data to renderer function. See itemContext section. Any node can be defined as a parent by supplying a children property, which is an array of one or more node definitions. (Note: lazy-loading is not supported in navigation list so children property should be a non empty array)

Example: Basic JSON Tree definition


[
  {
    "attr": {
              "id": "home",
              "title": "Home"
            },
  },
  {
    "attr": {
              "id": "news",
              "title": "News"
            }
  },
  {
     "attr": {
               "id": "blogs",
               "title": "Blogs"
             },
     "children": [ {

                      "attr": {
                                  "id": "today",
                                  "title": "Today"
                              }
                   },
                   {
                      "attr": {
                                  "id": "yesterday",
                                  "title": "Yesterday"
                              }
                   }
                 ]
  }
]


Any list item can be disabled by adding the oj-disabled class to that element. As with any DOM change, doing so post-init requires a refresh() of the component.

Icons

Sublist icons are inserted automatically. To add other icons to list items, include them in the markup and include the oj-navigationlist-item-icon class, as follows:

<ul id="navigationlist">
  <li id="foo"><a href="#"><span class="oj-navigationlist-item-icon demo-icon-font-24 demo-palette-icon-24"></span>Foo</a></li>
</ul>

Styling

Class(es) Description
oj-navigationlist-stack-icon-label Add this class to display Navigation List with Stacked icon and label. Applicable only when edge is top.
oj-navigationlist-category-divider Use this class to add horizontal divider line between two categories of items.
oj-navigationlist-item-icon Use this class to add icon to list item.
oj-navigationlist-item-title When arbitrary content is placed in side item, mark item title using this marker class.

Example of item markup with arbitrary content.

       
<li>
 <div>
     <span class="oj-navigationlist-item-title">Play</span>
     <button>Button</button>
 </div>
</li>
       
       

oj-navigationlist-item-text-wrap Use this class to wrap item label text.
oj-navigationlist-item-dividers Use this class to show dividers between horizontal navigation list items.
oj-sm-condense Use this class to condense horizontal navigation list items on small and up screens.
oj-md-condense Use this class to condense horizontal navigation list items on medium and up screens.
oj-lg-condense Use this class to condense horizontal navigation list items on large and up screens.
oj-xl-condense Use this class to condense horizontal navigation list items on extra large and up screens.

Touch End User Information

Target Gesture Action
List Item Tap Selects the item.
Press & Hold Display context menu
Group Item Tap Expand or collapse the group item if drillMode is set to collapsible. When drillMode is set to sliding, sublist will silde in. When drillMode is set to none, group item will be selecetd.
Press & Hold Display context menu
Hierarchical Menu button Tap Open menu. Refer menu button touch documentation. Note: This is applicable only for Sliding Navigation List.
Previous Icon or List Header Tap Collapses the sublist and slides to parent list. Note: This is applicable only for Sliding Navigation List.

Keyboard End User Information

Target Key Action
List Item Enter or Space Selects list item.
UpArrow Moves focus to the previous visible list item.
DownArrow Moves focus to the next visible list item
RightArrow (LeftArrow in RTL) For horizontal navigation list,focus will be moved to next visible item.
LeftArrow (RightArrow in RTL) For horizontal navigation list,focus will be moved to previous visible item.
Home Moves focus to the first visible list item.
End Moves focus to the last visible list item.
F2 If focus is on a list item, pressing F2 will make its contents accessible using TAB.
Esc When F2 mode is enabled, press Esc to exit F2 mode.
Shift+Tab Move fous to hierarchical menu button.Only applicable for sliding navigation list and when hierarchial menu button is enabled.
Group Item RightArrow (LeftArrow in RTL) If focus is on collapsed node, expands the sub list.
LeftArrow (RightArrow in RTL) If focus is on expanded node, collapses the sub list.
List Item in sublist Esc Applicable only for sliding navigation list. If focus is in a sub list, closes the sublist and moves focus to the parent list item.
Hierarchical Menu button Enter Open menu. Refer menu button keyboard documentation. Note: This target is visible only for Sliding Navigation List.
Tab Moves focus to current list item. Note: This target is visible only for Sliding Navigation List.
Shift + Tab Moves focus to Previous Icon. Note: This target is visible only for Sliding Navigation List.
Previous Icon or List Header Enter Collapses the sublist and slides to parent list.Note: This target is visible only for Sliding Navigation List.
Tab Moves focus to Hierarchical Menu button. Note: This target is visible only for Sliding Navigation List.

Disabled items will not receive keyboard focus and do not allow any interaction.

Item Context

For all item options, developers can specify a function as the return value. The function takes a single argument, which is an object that contains contextual information about the particular item. This gives developers the flexibility to return different value depending on the context.

The context paramter contains the following keys:

Key Description
component A reference to the NavigationList widget constructor.
datasource A reference to the data source object. (Not available for static content)
index The index of the item, where 0 is the index of the first item. In the hierarchical case the index is relative to its parent.
key The key of the item.
data The data object for the item.
parentElement The list item element. The renderer can use this to directly append content.

If the data is hierarchical, the following additional contextual information are available:

Key Description
depth The depth of the item. The depth of the first level children under the invisible root is 1.
parentKey The key of the parent item. The parent key is null for root node.
leaf Whether the item is a leaf or a group item.

Performance

Data Set Size

As a rule of thumb, it's recommended that applications limit the amount of data to display. Displaying large number of items in Navigation List makes it hard for user to find what they are looking for, but affects the load time. If displaying large number of items is neccessary, it is recommended to group the items in to hierarchial navigation list.

Item Content

Navigation List allows developers to specify arbitrary content inside its item. In order to minimize any negative effect on performance, you should avoid putting a large number of heavy-weight components inside because as you add more complexity to the structure, the effect will be multiplied because there can be many items in the Navigation List.

Expand All

While Navigation List provides a convenient way to initially expand all group items, it might have an impact on the initial rendering performance since expanding each group item might cause a fetch from the server depending on the TreeDataSource. Other factors that could impact performance includes the depth of the tree, and the number of children in each level.

Accessibility

Disabled content: JET supports an accessible luminosity contrast ratio, as specified in WCAG 2.0 - Section 1.4.3 "Contrast", in the themes that are accessible. (See the "Theming" chapter of the JET Developer Guide for more information on which themes are accessible.) Note that Section 1.4.3 says that text or images of text that are part of an inactive user interface component have no contrast requirement. Because disabled content may not meet the minimum contrast ratio required of enabled content, it cannot be used to convey meaningful information.

Reading direction

The only supported way to set the reading direction (LTR or RTL) is to set 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 navigation list must be refresh()ed, or the page must be reloaded.

Pseudo-selectors

The :oj-navigationlist pseudo-selector can be used in jQuery expressions to select JET Navigation Lists. For example:

$( ":oj-navigationlist" ) // selects all JET Navigation lists on the page
$myEventTarget.closest( ":oj-navigationlist" ) // selects the closest ancestor that is a JET Navigation lists

Initializer

.ojNavigationList(options)

Creates a JET Navigation List.
Parameters:
Name Type Argument Description
options Object <optional>
a map of option-value pairs to set on the component
Source:
Examples

Initialize the Navigation list with no options specified:

$( ".selector" ).ojNavigationList();

Initialize the Navigation list with some options and callbacks specified:

$( ".selector" ).ojNavigationList( { "drillMode": "none", "beforeSelect": function( event, ui ) {} } );

Initialize the Navigation list via the JET ojComponent binding:

<div id="navigationlist" data-bind="ojComponent: { component: 'ojNavigationList',
                                        drillMode: 'none',
                                        beforeSelect: beforeSelectItem }">

Options

contextMenu :Object

JQ selector identifying the JET Menu that the 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 specified JET Menu.

To specify a JET context menu on a DOM element that is not a JET component, see the ojContextMenu binding.

To make the page semantically accurate from the outset, applications are encouraged to specify the context menu via the standard HTML5 syntax shown in the below example. When the component is initialized, the context menu thus specified will be set on the component.

After create time, the contextMenu option should be set via this API, not by setting the DOM attribute.

Default Value:
  • null
Inherited From:
Source:
Examples

Initialize a JET component with a context menu:

// via recommended HTML5 syntax:
<div id="myComponent" contextmenu="myMenu" data-bind="ojComponent: { ... }>

// via JET initializer (less preferred) :
// Foo is the component, e.g., InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo({ "contextMenu": "#myMenu" });

Get or set the contextMenu option, after initialization:

// getter
// Foo is the component, e.g., InputText, InputNumber, Select, etc.
var menu = $( ".selector" ).ojFoo( "option", "contextMenu" );

// setter
// Foo is the component, e.g., InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo( "option", "contextMenu", ".my-marker-class" );

Set a JET context menu on an ordinary HTML element:

<a href="#" id="myAnchor" contextmenu="myMenu" data-bind="ojContextMenu: {}">Some text

currentItem :Object

Key of the current item. Current item is the list item which is having active focus. Note that if currentItem is set to an item that is currently not available (not fetched or inside a collapsed parent node), then the value is ignored.
Default Value:
  • null
Source:
Examples

Get the current item:

$( ".selector" ).ojNavigationList("option", "currentItem");

Set the current item on the NavigationList during initialization:

$(".selector").ojNavigationList({"currentItem", "item2"});

data :oj.TableDataSource|oj.TreeDataSource

The data source for the NavigationList accepts either a oj.TableDataSource or oj.TreeDataSource. See the data source section in the introduction for out of the box data source types. If the data attribute is not specified, the child elements are used as content. If there's no content specified, then an empty list is rendered.
Default Value:
  • null
Source:
Examples

Initialize the NavigationList with a one-dimensional array:

$( ".selector" ).ojNavigationList({ "data": new oj.ArrayTableDataSource([1,2,3])});

Initialize the NavigationList with an oj.Collection:

$( ".selector" ).ojNavigationList({ "data": new oj.CollectionTableDataSource(collection)});

display :string

Whether to display both the label and icons ("all") or just the icons ("icons"). In the latter case, the label is displayed in a tooltip instead, unless a tooltip was already supplied at create time. Note: display="icons" is valid only when drillMode=none and navigation list is a flat list. It is also mandatory to provide icons for each item as stated in icons section.
Supported Values:
Name Type Description
"all" string Display both the label and icons.
"icons" string Display only the icons.This option
Default Value:
  • "all"
Source:
Examples

Initialize the NavigationList with the display option specified:

$( ".selector" ).ojNavigationList( { "display": "icons" } );

Get or set the display option, after initialization:

// getter
var display = $( ".selector" ).ojNavigationList( "option", "display" );

// setter
$( ".selector" ).ojNavigationList( "option", "display", "icons" );

drillMode :string

Defines style of navigation used to drill down hierarchical list items.
  • none
  • collapsible
  • sliding
Supported Values:
Name Type Description
"none" string All group items are expanded by default and user not allowed to collapse them.
"collapsible" string Allows user to expand and collapse group items. If there are more than two levels in hierarchy, sliding is preferered drill mode.
"sliding" string This is typically used for hierarchical lists. This allows user to view one level at a time.
Default Value:
  • "none"
Source:
Examples

Initialize the menu with the drillMode option specified:

$( ".selector" ).ojNavigationList({ drillMode: "collapsible" });

Get the drillMode option, after initialization:

// getter
var drillMode = $( ".selector" ).ojNavigationList( "option", "drillMode" );

edge :string|null

The position of the Navigation List. Valid Values: top and start.

NOTE: when value is top,"none" is the only supported drillMode and it also does't support hierarchical items.

Supported Values:
Name Type Description
"top" string This renders list items horizontally.
"start" string This renders list items vertically.
Default Value:
  • "start"
Source:

expanded :Array|string

Specifies which items in NavigationList should be expanded. Specifies "all" value to expand all items. Specifies an array of keys to expand specific items. The default value is "auto", which means that NavigationList will determine which items are expanded by default. Specifically, if drillMode is set to "none", then all items are expanded, any other values for drillMode will not cause any items to expand by default. Note that expanded does not return the currently expanded items. This only returns what is specified by default. To retrieve the keys of currently expanded items, use the getExpanded method.
Default Value:
  • []
Source:

hierarchyMenuDisplayThresholdLevel :number|null

Specifies the level at which user can see hiearchical menu button.This is only valid when drillMode set to sliding. Default value is 0, shows hiearchical menu always. If value is -1, then it will never be shown.

The default value for hierarchyMenuDisplayThresholdLevel varies by theme. Each theme can set its default by setting $navigationListHierarchyMenuDisplayThresholdLevelOptionDefault as seen in the example below.

Default Value:
  • Varies by theme. "0" if not specified in theme.
Source:
Examples

Initialize the navigation list with the hierarchyMenuDisplayThresholdLevel option specified:

$( ".selector" ).ojNavigationList( { "hierarchyMenuDisplayThresholdLevel": "4" } );

Get or set the hierarchyMenuDisplayThresholdLevel option, after initialization:

// getter
var display = $( ".selector" ).ojNavigationList( "option", "hierarchyMenuDisplayThresholdLevel" );

// setter
$( ".selector" ).ojNavigationList( "option", "hierarchyMenuDisplayThresholdLevel", "4" );

Set the default in the theme (SCSS) :

$navigationListHierarchyMenuDisplayThresholdLevelOptionDefault: -1 !default;

item

The item option contains a subset of options for items.
Source:

item.renderer :function(Object)|null

The renderer function that renders the content of the item. See itemContext in the introduction to see the object passed into the renderer function. The function returns either a String or a DOM element of the content inside the item. If the developer chooses to manipulate the list element directly, the function should return nothing. If no renderer is specified, Navigation List will treat the data as a String.
Default Value:
  • null
Source:
Examples

Initialize the NavigationList with a renderer:

$( ".selector" ).ojNavigationList({ "data":data, "item": { "renderer": function(itemContext) {
                                           return itemContext['data'].get('FIRST_NAME');}}});

Get or set the renderer option, after initialization:

// set the renderer function
$( ".selector" ).ojNavigationList( "option", "item.renderer", myFunction});

item.selectable :function(Object)|boolean

Whether the item is selectable. See itemContext in the introduction to see the object passed into the selectable function.
Default Value:
  • true
Source:
Example

Initialize the NavigationList such that the first 3 items are not selectable:

$( ".selector" ).ojNavigationList({ "data":data, "item": { "selectable": function(itemContext) {
                                           return itemContext['index'] > 3;}}});
Navigation List supports two different look-and-feel depends on its usage level, one is application level and other is page level.
Supported Values:
Name Type Description
"application" string Render Navigation List for application level navigation.
"page" string Render Navigation List for page level navigation.
Default Value:
  • "page"
Source:
Examples

Initialize the NavigationList with the navigationLevel option specified:

$( ".selector" ).ojNavigationList( { "navigationLevel": "application" } );

Get or set the navigationLevel option, after initialization:

// getter
var display = $( ".selector" ).ojNavigationList( "option", "navigationLevel" );

// setter
$( ".selector" ).ojNavigationList( "option", "navigationLevel", "application" );

rootAttributes :Object

Attributes specified here will be set on the component's root DOM element at creation time. This is particularly useful for components like Dialog that wrap themselves in a new root element at creation time.

The supported attributes are id, which overwrites any existing value, and class and style, which are appended to the current class and style, if any.

Setting this option after component creation has no effect. At that time, the root element already exists, and can be accessed directly via the widget method, per the second example below.

Default Value:
  • null
Inherited From:
Source:
Examples

Initialize a JET component, specifying a set of attributes to be set on the component's root DOM element:

// Foo is the component, e.g., Menu, Button, InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo({ "rootAttributes": {
  "id": "myId",
  "style": "max-width:100%; color:blue;",
  "class": "my-class"
}});

After initialization, rootAttributes should not be used. It is not needed at that time, as attributes of the root DOM element can simply be set directly, using widget:

// Foo is the component, e.g., Menu, Button, InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo( "widget" ).css( "height", "100px" );
$( ".selector" ).ojFoo( "widget" ).addClass( "my-class" );

rootLabel :string

Label for top level list items.

NOTE: This is needed only for sliding navigation list where this will be used as title for the top level list elements.

Default Value:
  • Navigation List
Source:

selection :string|null

Item key of currently selected list item. If the value is modified by an application, navigation list UI is modified to match the new value.
Default Value:
  • null
Source:

translations :Object

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 this component has (or inherits) translations, their documentation immediately follows this doc entry.

Default Value:
  • an object containing all resources relevant to the component and all its superclasses, or null if none
Inherited From:
Source:
Examples

Initialize the component, overriding some translated resources. This syntax leaves the other translations intact at create time, but not if called after create time:

// Foo is InputDate, InputNumber, etc.
$( ".selector" ).ojFoo({ "translations": { someKey: "someValue",
                                           someOtherKey: "someOtherValue" } });

Get or set the translations option, after initialization:

// Get one.  (Foo is InputDate, InputNumber, etc.)
var value = $( ".selector" ).ojFoo( "option", "translations.someResourceKey" );

// Get all.  (Foo is InputDate, InputNumber, etc.)
var values = $( ".selector" ).ojFoo( "option", "translations" );

// Set one, leaving the others intact.  (Foo is InputDate, InputNumber, etc.)
$( ".selector" ).ojFoo( "option", "translations.someResourceKey", "someValue" );

// Set many.  Any existing resource keys not listed are lost.  (Foo is InputDate, InputNumber, etc.)
$( ".selector" ).ojFoo( "option", "translations", { someKey: "someValue",
                                                    someOtherKey: "someOtherValue" } );

Binding Attributes

Binding attributes are similar to component options, but are exposed only via the ojComponent binding.

item.template :string|null

The knockout template used to render the content of the item. This attribute is only exposed via the ojComponent binding, and is not a component option.
Default Value:
  • null
Source:
Example

Specify the template when initializing NavigationList:

// set the template
<div id="navlist" data-bind="ojComponent: {component: 'ojNavigationList', data: dataSource, template: 'my_template'}"></div>

Sub-ID's

Each subId locator object contains, at minimum, a subId property, whose value is a string that identifies a particular DOM node in this component. It can have additional properties to further specify the desired node. See getNodeBySubId and getSubIdByNode methods for more details.

Properties:
Name Type Description
subId string Sub-id string to identify a particular dom node.

Following are the valid subIds:

oj-navigationlist-hierarchical-button

Sub-ID for the ojNavigationList component's hierarchical menu button element. See the getNodeBySubId method for details.

To lookup the hierarchical menu button the locator object should have the following:
  • subId: 'oj-navigationlist-hierarchical-button'
Source:
Example

Get the hierarchical menu button element:

var node = $( ".selector" ).ojNavigationList( "getNodeBySubId", {'subId': 'oj-navigationlist-hierarchical-button'} );

oj-navigationlist-hierarchical-menu

Sub-ID for the ojNavigationList component's hierarchical menu element.

To lookup the hierarchical menu the locator object should have the following:
  • subId: 'oj-navigationlist-hierarchical-menu'
Source:
Example

Get the hierarchical menu element:

var node = $( ".selector" ).ojNavigationList( "getNodeBySubId", {'subId': 'oj-navigationlist-hierarchical-menu'} );

oj-navigationlist-item

Sub-ID for the ojNavigationList component's list item element.

To lookup the list items the locator object should have the following:

  • subId: 'oj-navigationlist-item'
  • key: the key of the item
Source:
Example

Get the list item element with key 'foo':

var node = $( ".selector" ).ojNavigationList( "getNodeBySubId", {'subId': 'oj-navigationlist-item', 'key': 'foo'} );

Events

#beforeCollapse

Triggered before an item is collapse via the expanded option, the collapse method, or via the UI. To prevent the item being collapsed, return false from event handler or invoke event.preventDefault().
Properties:
Name Type Description
event Event jQuery event object
ui Object Parameters
Properties
Name Type Description
key Object the key of the item to be collapse
item jQuery the item to be collapse
Source:
Examples

Initialize the NavigationList with the beforeCollapse callback specified:

$( ".selector" ).ojNavigationList({
    "beforeCollapse": function( event, ui ) {
        // return false to veto the event, which prevents the item to collapse
    }
});

Bind an event listener to the ojbeforecollapse event:

$( ".selector" ).on( "ojbeforecollapse", function( event, ui ) {} );

#beforeCurrentItem

Triggered before the current item is changed via the currentItem option or via the UI. To prevent the item being focused, return false from event handler or invoke event.preventDefault().
Properties:
Name Type Description
event Event jQuery event object
ui Object Parameters
Properties
Name Type Description
previousKey Object the key of the previous item
previousItem jQuery the previous item
key Object the key of the new current item
item jQuery the new current item
Source:
Examples

Initialize the NavigationList with the beforeCurrentItem callback specified:

$( ".selector" ).ojNavigationList({
    "beforeCurrentItem": function( event, ui ) {
        // return false to veto the event, which prevents the item to become focus
    }
});

Bind an event listener to the ojbeforecurrentitem event:

$( ".selector" ).on( "ojbeforecurrentitem", function( event, ui ) {} );

#beforeExpand

Triggered before an item is expand via the expanded option, the expand method, or via the UI. To prevent the item being expanded, return false from event handler or invoke event.preventDefault().
Properties:
Name Type Description
event Event jQuery event object
ui Object Parameters
Properties
Name Type Description
key Object the key of the item to be expand
item jQuery the item to be expand
Source:
Examples

Initialize the NavigationList with the beforeExpand callback specified:

$( ".selector" ).ojNavigationList({
    "beforeExpand": function( event, ui ) {
        // return false to veto the event, which prevents the item to expand
    }
});

Bind an event listener to the ojbeforeexpand event:

$( ".selector" ).on( "ojbeforeexpand", function( event, ui ) {} );

#beforeSelect

Triggered before this list item is selected. To prevent the item selection, return false from event handler or invoke event.preventDefault().

The ui.key contains item key which uniquely identifies the item. ui.item payload field contains item element being selected.

Properties:
Name Type Description
event Event jQuery event object
ui Object Parameters
Properties
Name Type Description
key Object Selected list item key.
item jQuery Selected list item.
Source:
Examples

Initialize the Navigation List with the beforeSelect callback specified:

$( ".selector" ).ojNavigationList({
    "beforeSelect": function( event, ui ) {}
});

Bind an event listener to the ojbeforeselect event:

$( ".selector" ).on( "ojbeforeselect", function( event, ui ) {} );

#collapse

Triggered after an item has been collapsed via the expanded option, the collapse method, or via the UI.
Properties:
Name Type Description
event Event jQuery event object
ui Object Parameters
Properties
Name Type Description
key Object The key of the item that was just collapsed.
item jQuery The list item that was just collapsed.
Source:
Examples

Initialize the NavigationList with the expand callback specified:

$( ".selector" ).ojNavigationList({
    "collapse": function( event, ui ) {}
});

Bind an event listener to the ojcollapse event:

$( ".selector" ).on( "ojcollapse", function( event, ui ) {} );

destroy

Triggered before the component is destroyed. This event cannot be canceled; the component will always be destroyed regardless.

Inherited From:
Source:
Examples

Initialize component with the destroy callback

// Foo is Button, InputText, etc.
$(".selector").ojFoo({
  'destroy': function (event, data) {}
});

Bind an event listener to the destroy event

$(".selector").on({
  'ojdestroy': function (event, data) {
      window.console.log("The DOM node id for the destroyed component is : %s", event.target.id);
  };
});

#expand

Triggered after an item has been expanded via the expanded option, the expand method, or via the UI.
Properties:
Name Type Description
event Event jQuery event object
ui Object Parameters
Properties
Name Type Description
key Object The key of the item that was just expanded.
item jQuery The list item that was just expanded.
Source:
Examples

Initialize the NavigationList with the expand callback specified:

$( ".selector" ).ojNavigationList({
    "expand": function( event, ui ) {}
});

Bind an event listener to the ojexpand event:

$( ".selector" ).on( "ojexpand", function( event, ui ) {} );

#optionChange

Fired whenever a supported component option changes, whether due to user interaction or programmatic intervention. If the new value is the same as the previous value, no event will be fired.
Properties:
Name Type Description
event Event jQuery event object
ui Object Parameters
Properties
Name Type Description
option string the name of the option that is changing
previousValue boolean the previous value of the option
value boolean the current value of the option
optionMetadata Object information about the option that is changing
Properties
Name Type Description
writeback string "shouldWrite" or "shouldNotWrite". For use by the JET writeback mechanism.
Source:
Examples

Initialize component with the optionChange callback

$(".selector").ojNavigationList({
  'optionChange': function (event, data) {
       if (data['option'] === 'selection') { // handle selection change }
   }
});

Bind an event listener to the ojoptionchange event

$(".selector").on({
  'ojoptionchange': function (event, data) {
      window.console.log("option that changed is: " + data['option']);
  };
});

Methods

collapse(key, vetoable)

Collapse an item.

Note when vetoable is set to false, beforeCollapse event will still be fired but the event cannot be veto.

Parameters:
Name Type Description
key Object the key of the item to collapse
vetoable boolean if event is vetoable
Source:
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining.

expand(key, vetoable)

Expand an item.

Note when vetoable is set to false, beforeExpand event will still be fired but the event cannot be veto.

Parameters:
Name Type Description
key Object the key of the item to expand
vetoable boolean if event is vetoable
Source:
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining.

getExpanded() → {Array}

Gets the key of currently expanded items.
Source:
Returns:
array of keys of currently expanded items
Type
Array

getNodeBySubId(locator) → {Element|null}

Returns the component DOM node indicated by the locator parameter.

If the locator or its subId is null, then this method returns the element on which this component was initialized.

If a subId was provided but no corresponding node can be located, then this method returns null. For more details on subIds, see the subIds section.

Parameters:
Name Type Description
locator Object An Object containing, at minimum, a subId property, whose value is a string that identifies a particular DOM node in this component.

If this component has (or inherits) any subIds, then they are documented in the "Sub-ID's" section of this document.

Subclasses of this component may support additional fields of the locator Object, to further specify the desired node.

Inherited From:
Source:
Returns:
The DOM node located by the subId string passed in locator, or null if none is found.
Type
Element | null
Example

Get the node for a certain subId:

// Foo is ojInputNumber, ojInputDate, etc.
var node = $( ".selector" ).ojFoo( "getNodeBySubId", {'subId': 'oj-some-sub-id'} );

option(optionName, value) → {Object|undefined}

This method has several overloads, which get and set component options and their fields. The functionality is unchanged from that provided by JQUI. See the examples for details on each overload.

Parameters:
Name Type Argument Description
optionName string | Object <optional>
the option name (string, first two overloads), or the map (Object, last overload). Omitted in the third overload.
value Object <optional>
a value to set for the option. Second overload only.
Inherited From:
Source:
Returns:
The getter overloads return the retrieved value(s). When called via the public jQuery syntax, the setter overloads return the object on which they were called, to facilitate method chaining.
Type
Object | undefined
Examples

First overload: get one option:

This overload accepts a (possibly dot-separated) optionName param as a string, and returns the current value of that option.

var isDisabled = $( ".selector" ).ojFoo( "option", "disabled" ); // Foo is Button, Menu, etc.

// For object-valued options, dot notation can be used to get the value of a field or nested field.
var startIcon = $( ".selector" ).ojButton( "option", "icons.start" ); // icons is object with "start" field

Second overload: set one option:

This overload accepts two params: a (possibly dot-separated) optionName string, and a new value to which that option will be set.

$( ".selector" ).ojFoo( "option", "disabled", true ); // Foo is Button, Menu, etc.

// For object-valued options, dot notation can be used to set the value
// of a field or nested field, without altering the rest of the object.
$( ".selector" ).ojButton( "option", "icons.start", myStartIcon ); // icons is object with "start" field

Third overload: get all options:

This overload accepts no params, and returns a map of key/value pairs representing all the component options and their values.

var options = $( ".selector" ).ojFoo( "option" ); // Foo is Button, Menu, etc.

Fourth overload: set one or more options:

This overload accepts a single map of option-value pairs to set on the component. Unlike the first two overloads, dot notation cannot be used.

$( ".selector" ).ojFoo( "option", { disabled: true, bar: 42 } ); // Foo is Button, Menu, etc.

refresh()

Refreshes the visual state of the Navigation List. JET components require a refresh() after the DOM is programmatically changed underneath the component.

This method does not accept any arguments.

Source:
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining.
Example

Invoke the refresh method:

$( ".selector" ).ojNavigationList( "refresh" );

Non-public Methods

Note: Extending JET components is not currently supported. Thus, non-public methods are for internal use only.

<protected, static> _AfterCreate()

Initialize the NavigationList after creation
Source:

<protected, static> _ComponentCreate()

Create the Navigation List
Source:

<protected> _AfterCreate()

This method is called after _ComponentCreate, but before the create event is fired. The JET base component does tasks here that must happen after the component (subclass) has created itself in its override of _ComponentCreate. Notably, the base component handles the rootAttributes and contextMenu options here, since those options operate on the component root node, which for some components is created in their override of _ComponentCreate.

Subclasses should override this method only if they have tasks that must happen after a superclass's implementation of this method, e.g. tasks that must happen after the context menu is set on the component.

Overrides of this method should call this._super first.

Inherited From:
Source:

<protected> _AfterCreateEvent()

This method is called after the create event is fired. Components usually should not override this method, as it is rarely correct to wait until after the create event to perform a create-time task.

An example of a correct usage of this method is Dialog's auto-open behavior, which needs to happen after the create event.

Only behaviors (like Dialog auto-open behavior) should occur in this method. Component initialization must occur earlier, before the create event is fired, so that create listeners see a fully inited component.

Overrides of this method should call this._super first.

Do not confuse this method with the _AfterCreate method, which is more commonly used.

Inherited From:
Source:

<protected> _CompareOptionValues(option, value1, value2) → {boolean}

Compares 2 option values for equality and returns true if they are equal; false otherwise.

Parameters:
Name Type Description
option String the name of the option
value1 Object first value
value2 Object another value
Inherited From:
Source:
Returns:
Type
boolean

<protected> _ComponentCreate()

All component create-time initialization lives in this method, except the logic that specifically needs to live in _InitOptions, _AfterCreate, or _AfterCreateEvent, per the documentation for those methods. All DOM creation must happen here, since the intent of _AfterCreate, which is called next, is to contain superclass logic that must run after that DOM is created.

Overrides of this method should call this._super first.

Summary of create-time methods that components can override, in the order that they are called:

  1. _InitOptions
  2. _ComponentCreate (this method)
  3. _AfterCreate
  4. (The create event is fired here.)
  5. _AfterCreateEvent

For all of these methods, the contract is that overrides must call this._super first, so e.g., the _ComponentCreate entry means baseComponent._ComponentCreate, then _ComponentCreate in any intermediate subclasses, then _ComponentCreate in the leaf subclass.

Inherited From:
Source:

<protected> _create()

This method is final in JET. Components should instead override one or more of the overridable create-time methods listed in _ComponentCreate.

Inherited From:
Source:

<protected> _getCreateOptions()

This method is not used in JET. Components should instead override _InitOptions.

Inherited From:
Source:

<protected> _GetReadingDirection() → {string}

Determines whether the component is LTR or RTL.

Component responsibilities:

  • All components must determine directionality exclusively by calling this protected superclass method. (So that any future updates to the logic can be made in this one place.)
  • Components that need to know the directionality must call this method at create-time and from refresh(), and cache the value.
  • Components should not call this at other times, and should instead use the cached value. (This avoids constant DOM queries, and avoids any future issues with component reparenting (i.e. popups) if support for directional islands is added.)

App responsibilities:

  • The app specifies directionality by setting the HTML "dir" attribute on the <html> node. When omitted, the default is "ltr". (Per-component directionality / directional islands are not currently supported due to inadequate CSS support.)
  • As with any DOM change, the app must refresh() the component if the directionality changes dynamically. (This provides a hook for component housekeeping, and allows caching.)
Default Value:
  • "ltr"
Inherited From:
Source:
Returns:
the reading direction, either "ltr" or "rtl"
Type
string

<protected> _GetSavedAttributes(element) → {Object|null}

Gets the saved attributes for the provided element.

If you don't override _SaveAttributes and _RestoreAttributes, then this will return null.

If you override _SaveAttributes to call _SaveAllAttributes, then this will return all the attributes. If you override _SaveAttributes/_RestoreAttributes to do your own thing, then you may also have to override _GetSavedAttributes to return whatever you saved if you need access to the saved attributes.

Parameters:
Name Type Description
element Object jQuery selection, should be a single entry
Inherited From:
Source:
Returns:
savedAttributes - attributes that were saved for this element in _SaveAttributes, or null if none were saved.
Type
Object | null

<protected> _init()

JET components should almost never implement this JQUI method. Please consult an architect if you believe you have an exception. Reasons:

  • This method is called at create time, after the create event is fired. It is rare for that to be the appropriate time to perform a create-time task. For those rare cases, we have the _AfterCreateEvent method, which is preferred over this method since it is called only at that time, not also at re-init time (see next).
  • This method is also called at "re-init" time, i.e. when the initializer is called after the component has already been created. JET has not yet identified any desired semantics for re-initing a component.
Inherited From:
Source:

<protected> _InitOptions(originalDefaults, constructorOptions)

This method is called before _ComponentCreate, at which point the component has not yet been rendered. Component options should be initialized in this method, so that their final values are in place when _ComponentCreate is called.

This includes getting option values from the DOM, where applicable, and coercing option values (however derived) to their appropriate data type if needed.

No work other than setting options should be done in this method. In particular, nothing should be set on the DOM until _ComponentCreate, e.g. setting the disabled DOM attribute from the disabled option.

A given option (like disabled) appears in the constructorOptions param iff the app set it in the constructor:

  • If it appears in constructorOptions, it should win over what's in the DOM (e.g. disabled DOM attribute). If for some reason you need to tweak the value that the app set, then enable writeback when doing so: this.option('foo', bar, {'_context': {writeback: true, internalSet: true}}).
  • If it doesn't appear in constructorOptions, then that option definitely is not bound, so writeback is not needed. So if you need to set the option (e.g. from a DOM attribute), use this.option('foo', bar, {'_context': {internalSet: true}}).

Overrides of this method should call this._super first.

Parameters:
Name Type Argument Description
originalDefaults Object original default options defined on the component and its ancestors
constructorOptions Object <nullable>
options passed into the widget constructor
Inherited From:
Source:

<protected> _IsEffectivelyDisabled() → {boolean}

Determines whether this component is effectively disabled, i.e. it has its 'disabled' attribute set to true or it has been disabled by its ancestor component.

Inherited From:
Source:
Returns:
true if the component has been effectively disabled, false otherwise
Type
boolean

<protected> _NotifyAttached()

Notifies the component that its subtree has been connected to the document programmatically after the component has been created.

Inherited From:
Source:

<protected> _NotifyContextMenuGesture(menu, event, eventType)

When the contextMenu option is set, this method is called when the user invokes the context menu via the default gestures: right-click, Press & Hold, and Shift-F10. Components should not call this method directly.

The default implementation simply calls this._OpenContextMenu(event, eventType). Overrides of this method should call that same method, perhaps with additional params, not menu.open().

This method may be overridden by components needing to do things like the following:

  • Customize the launcher or position passed to _OpenContextMenu(). See that method for guidance on these customizations.
  • Customize the menu contents. E.g. some components need to enable/disable built-in commands like Cut and Paste, based on state at launch time.
  • Bail out in some cases. E.g. components with UX approval to use PressHoldRelease rather than Press & Hold can override this method to say if (eventType !== "touch") this._OpenContextMenu(event, eventType);. When those components detect the alternate context menu gesture (e.g. PressHoldRelease), that separate listener should call this._OpenContextMenu(), not this method (_NotifyContextMenuGesture()), and not menu.open().

Components needing to do per-launch setup like the above tasks should do so in an override of this method, not in a beforeOpen listener or an _OpenContextMenu() override. This is discussed more fully here.

Parameters:
Name Type Description
menu Object The JET Menu to open as a context menu. Always non-null.
event Event What triggered the menu launch. Always non-null.
eventType string "mouse", "touch", or "keyboard". Never null.
Inherited From:
Source:

<protected> _NotifyDetached()

Notifies the component that its subtree has been removed from the document programmatically after the component has been created.

Inherited From:
Source:

<protected> _NotifyHidden()

Notifies the component that its subtree has been made hidden programmatically after the component has been created.

Inherited From:
Source:

<protected> _NotifyShown()

Notifies the component that its subtree has been made visible programmatically after the component has been created.

Inherited From:
Source:

<protected> _OpenContextMenu(event, eventType, openOptions, submenuOpenOptions, shallow)

The only correct way for a component to open its context menu is by calling this method, not by calling Menu.open() or _NotifyContextMenuGesture(). This method should be called in two cases:

  • This method is called by _NotifyContextMenuGesture() and its overrides. That method is called when the baseComponent detects the default context menu gestures: right-click, Press & Hold, and Shift-F10.
  • Components with UX-approved support for alternate context menu gestures like PressHoldRelease should call this method directly when those gestures are detected.

Components needing to customize how the context menu is launched, or do any per-launch setup, should do so in the caller of this method, (which is one of the two callers listed above), often by customizing the params passed to this method (_OpenContextMenu) per the guidance below. This setup should not be done in the following ways:

  • Components should not perform setup in a beforeOpen listener, as this can cause a race condition where behavior depends on who got their listener registered first: the component or the app. The only correct component use of a beforeOpen listener is when there's a need to detect whether something else launched the menu.
  • Components should not override this method (_OpenContextMenu), as this method is final. Instead, customize the params that are passed to it.

Guidance on setting OpenOptions fields:

Launcher:

Depending on individual component needs, any focusable element within the component can be the appropriate launcher for this launch.

Browser focus returns to the launcher on menu dismissal, so the launcher must at least be focusable. Typically a tabbable (not just focusable) element is safer, since it just focuses something the user could have focused on their own.

By default (i.e. if openOptions is not passed, or if it lacks a launcher field), the component init node is used as the launcher for this launch. If that is not focusable or is suboptimal for a given component, that component should pass something else. E.g. components with a "roving tabstop" (like Toolbar) should typically choose the current tabstop as their launcher.

The :focusable and :tabbable selectors may come in handy for choosing a launcher, e.g. something like this.widget().find(".my-class:tabbable").first().

Position:

By default, this method applies positioning that differs from Menu's default in the following ways: (The specific settings are subject to change.)

  • For mouse and touch events, the menu is positioned relative to the event, not the launcher.
  • For touch events, "my" is set to "start>40 center", to avoid having the context menu obscured by the user's finger.

Usually, if position needs to be customized at all, the only thing that needs changing is its "of" field, and only for keyboard launches (since mouse/touch launches should almost certainly keep the default "event" positioning). This situation arises anytime the element relative to which the menu should be positioned for keyboard launches is different than the launcher element (the element to which focus should be returned upon dismissal). For this case, { "position": {"of": eventType==="keyboard" ? someElement : "event"} } can be passed as the openOptions param.

Be careful not to clobber useful defaults by specifying too much. E.g. if you only want to customize "of", don't pass other fields like "my", since your value will be used for all modalities (mouse, touch, keyboard), replacing the modality-specific defaults that are usually correct. Likewise, don't forget the eventType==="keyboard" check if you only want to customize "of" for keyboard launches.

InitialFocus:

This method forces initialFocus to "menu" for this launch, so the caller needn't specify it.

Parameters:
Name Type Argument Description
event Event What triggered the context menu launch. Must be non-null.
eventType string "mouse", "touch", or "keyboard". Must be non-null. Passed explicitly since caller knows what it's listening for, and since events like contextmenu and click can be generated by various input modalities, making it potentially error-prone for this method to determine how they were generated.
openOptions Object <optional>
Options to merge with this method's defaults, which are discussed above. The result will be passed to Menu.open(). May be null or omitted. See also the shallow param.
submenuOpenOptions Object <optional>
Options to be passed through to Menu.open(). May be null or omitted.
shallow boolean <optional>
Whether to perform a deep or shallow merge of openOptions with this method's default value. The default and most commonly correct / useful value is false.
  • If true, a shallow merge is performed, meaning that the caller's position object, if passed, will completely replace this method's default position object.
  • If false or omitted, a deep merge is performed. For example, if the caller wishes to tweak position.of while keeping this method's defaults for position.my, position.at, etc., it can pass {"of": anOfValue} as the position value.

The shallow param is n/a for submenuOpenOptions, since this method doesn't apply any defaults to that. (It's a direct pass-through.)

Inherited From:
Source:

<protected> _RestoreAllAttributes()

Restores all the element's attributes which were saved in _SaveAllAttributes. This method is final in JET.

If a subclass wants to save/restore all attributes on create/destroy, then the subclass can override _SaveAttributes and call _SaveAllAttributes and also override _RestoreAttributes and call _RestoreAllAttributes.

Inherited From:
Source:

<protected> _RestoreAttributes()

Restore the attributes saved in _SaveAttributes.

_SaveAttributes is called during _create. And _RestoreAttributes is called during _destroy.

This base class default implementation does nothing.

We also have _SaveAllAttributes and _RestoreAllAttributes methods that save and restore all the attributes on an element. Component subclasses can opt into these _SaveAllAttributes/_RestoreAllAttributes implementations by overriding _SaveAttributes and _RestoreAttributes to call _SaveAllAttributes/_RestoreAllAttributes. If the subclass wants a different implementation (like save only the 'class' attribute), it can provide the implementation itself in _SaveAttributes/_GetSavedAttributes/_RestoreAttributes.

Inherited From:
Source:

<protected> _SaveAllAttributes(element)

Saves all the element's attributes within an internal variable. _RestoreAllAttributes will restore the attributes from this internal variable.

This method is final in JET. Subclasses can override _RestoreAttributes and call _RestoreAllAttributes.

The JSON variable will be held as:

[
  {
  "element" : element[i],
  "attributes" :
    {
      attributes[m]["name"] : {"attr": attributes[m]["value"], "prop": $(element[i]).prop(attributes[m]["name"])
    }
  }
]
Parameters:
Name Type Description
element Object jQuery selection to save attributes for
Inherited From:
Source:

<protected> _SaveAttributes(element)

Saves the element's attributes. This is called during _create. _RestoreAttributes will restore all these attributes and is called during _destroy.

This base class default implementation does nothing.

We also have _SaveAllAttributes and _RestoreAllAttributes methods that save and restore all the attributes on an element. Component subclasses can opt into these _SaveAllAttributes/_RestoreAllAttributes implementations by overriding _SaveAttributes and _RestoreAttributes to call _SaveAllAttributes/_RestoreAllAttributes. If the subclass wants a different implementation (like save only the 'class' attribute), it can provide the implementation itself in _SaveAttributes/_RestoreAttributes.

Parameters:
Name Type Description
element Object jQuery selection to save attributes for
Inherited From:
Source:

<protected> _SetRootAttributes()

Reads the rootAttributes option, and sets the root attributes on the component's root DOM element. See rootAttributes for the set of supported attributes and how they are handled.

Inherited From:
Source:
Throws:
if unsupported attributes are supplied.

<protected> _UnregisterChildNode()

Remove all listener references that were attached to the element which includes _activeable, _focusable and hoverable.
Inherited From:
Source: