Skip to main content

popMenu

The popMenu object provides a function for creating pop-up menus. It also provides a function to add/remove items to an existing pop-up menus.

Methods

create

pb.popMenu.create(menuData, triggerSelector, [filterTriggerSelector])

Create a new pop menu. A pop menu consists of one or more submenus defined by the menuStructure. A pop menu always displays one submenu at a time. Typically, it will start by showing the 'root' submenu.

Returns: Object - Returns a popMenu object which can be used directly to control various aspects of the menu that was created.

ParamTypeDefaultDescription
menuDataObject
menuData.menuStructureObject.<string, Submenu>The menu structure defines the all submenus associated with the popmenu. Typically, there should be a 'root' submenu defined here.
[menuData.startingMenu]string"root"Indicate which submenu should be shown when the pop menu opens.
[menuData.opensOn]string"click"The event name that triggers the menu to open.
[menuData.placement]'top left' | 'top right' | 'bottom right' | 'bottom left'"bottom left"How to position the menu against the element that triggered the menu to open.
[menuData.positionOffsetX]numberOffsets menu placement on x-axis.
[menuData.positionOffsetY]numberOffsets menu placement on y-axis.
[menuData.positionAgainstSelector]stringUse this to position the menu in relation to a different element. By default, the menu is positioned in relation to the element that triggers the menu.
[menuData.addMenuClass]stringAdd one or more classes to the menu element. Separate multiple classes with spaces.
[menuData.overlayClass]stringAdd one or more classes to the overlay element. Separate multiple classes with spaces.
[menuData.onBeforeShow]functionFunction to run before the menu opens.
triggerSelectorstringTarget the elements that trigger the pop menu to open.
[filterTriggerSelector]stringFurther filters the elements selected by the triggerSelector. Only these filtered elements trigger the pop menu to open.

add

pb.popMenu.add(popMenuId, params)

Add your own custom menu items to exising popMenus.

ParamTypeDescription
popMenuIdstringThe data-id attribute for the popMenu you want to add to.
paramsObject
params.idstringA unique id to identify the menu structure you are adding.
params.menuStructureObject.<string, Submenu>The menu structure to add. It should have a root level menu defined at the minimum.

remove

pb.popMenu.remove(popMenuId, params)

Remove custom menu items from exising popMenus.

ParamTypeDescription
popMenuIdstringThe data-id attribute value for the popMenu you want to remove from.
paramsObject
params.idstringThe unique id of the menu structure you are removing.

A Submenu consists of a title and the menu items associated with it.

Properties

NameTypeDescription
[title]stringThe title of the submenu.
itemsArray.<MenuItem>The menu items that appear for this submenu.

Represents individual items that are displayed for a Submenu.

Properties

NameTypeDescription
textstringThe label to show for the menu item.
[css]ObjectAn object with css styles to apply to the text.
[icon]stringA classname to apply an icon (e.g. pbi-cog).
[iconCss]ObjectAn object with css styles to apply to the icon.
[href]stringA URL to redirect to if the menu item is clicked.
[action]functionA function to run when the menu item is clicked.
[submenu]stringAllows the menu item to open another Submenu. The string corresponds to the key for the Submenu specified in the menuStructure.
[disabled]booleanIf true, the menu item is disabled.
[keepOpen]booleanIf true, the popMenu stays open if this menuItem is clicked.
[addSeparator]booleanIf true, a line will appear below this menuItem.