Skip to content

Treeview Item

A basic navigation link contained inside of a Treeview.

Note

This is a subclass of BaseMenuItem.

Constructor

Constructs a new TreeviewItem.

js
new TreeviewItem({
  menuItemElement,
  menuLinkElement,
  parentMenu,
  isSubmenuItem,
  childMenu,
  toggle,
  initialize,
});

The constructor will call BaseMenuItem's constructor with the provided options. It will also initialize the menu item if the initialize flag is set to true.

Parameters

NameTypeDescriptionDefault
optionsobjectThe options for generating the menu item.undefined
options.menuItemElementHTMLElementThe menu item in the DOM.undefined
options.menuLinkElementHTMLElementThe menu item's link in the DOM.undefined
options.parentMenuTreeviewThe parent menu.undefined
options.isSubmenuItembooleanA flag to mark if the menu item is controlling a submenu.false
options.childMenuTreeview, nullThe child menu.null
options.toggleTreeviewToggle, nullThe controller for the child menu.null
options.initializebooleanA flag to initialize the menu item immediately upon creation.true

Initialize

Initialize the menu item.

js
TreeviewItem.initialize();

Initialize will call the BaseMenuItem's initialize method as well as set the menu item's role to "none", the menu link's role to "treeitem", and the menu link's tabIndex to -1 in the DOM.

Properties

Properties are inherited from the BaseMenuItem class. There are no custom properties for the TreeviewItem class.

Getters and Setters

Getters and setters are inherited from the BaseMenuItem class. There are no custom getters and setters for the TreeviewItem class.

Methods

Methods are inherited from the BaseMenuItem class. The following methods are unique to or overwritten in the TreeviewItem class.

focus public

Focuses the menu item's link if the parent menu's shouldFocus value is true.

js
TreeviewItem.focus();

This will call the BaseMenuItem's focus method as well as set the menu link's tabIndex to 0 if the parent menu is the root menu.

blur public

Blurs the menu item's link if the parent menu's shouldFocus value is true.

js
TreeviewItem.blur();

This will call the BaseMenuItem's focus method as well as set the menu link's tabIndex to -1 if the parent menu is the root menu.