dijit/popup (version 1.10)

Summary

Used to show drop downs (ex: the select list of a ComboBox) or popups (ex: right-click context menus).

See the dijit/popup reference documentation for more information.

Property Summary

  • _beginZIndexZ-index of the first popup. (If first popup opens other popups they get a higher z-index.)
  • _idGen
  • _stackStack of currently popped up widgets. (someone opened _stack[0], and then it opened _stack[1], etc.)

Method Summary

  • _createWrapper(widget) Initialization for widgets that will be used as popups.
  • _repositionAll() If screen has been scrolled, reposition all the popups in the stack.
  • close(popup) Close specified popup and any popups that it parented.
  • getTopPopup() Compute the closest ancestor popup that's not a child of another popup.
  • hide(widget) Hide this popup widget (until it is ready to be shown).
  • moveOffScreen(widget) Moves the popup widget off-screen.
  • open(args) Popup the widget at the specified position

Properties

_beginZIndex
Defined by: dijit/popup

Z-index of the first popup. (If first popup opens other popups they get a higher z-index.)

_idGen
Defined by: dijit/popup
_stack
Defined by: dijit/popup

Stack of currently popped up widgets. (someone opened _stack[0], and then it opened _stack[1], etc.)

Methods

_createWrapper(widget)
Defined by dijit/popup

Initialization for widgets that will be used as popups. Puts widget inside a wrapper DIV (if not already in one), and returns pointer to that wrapper DIV.

Parameter Type Description
widget Widget
Returns:undefined
_repositionAll()
Defined by dijit/popup

If screen has been scrolled, reposition all the popups in the stack. Then set timer to check again later.

close(popup)
Defined by dijit/popup

Close specified popup and any popups that it parented. If no popup is specified, closes all popups.

Parameter Type Description
popup Widget
Optional
getTopPopup()
Defined by dijit/popup

Compute the closest ancestor popup that's not a child of another popup. Ex: For a TooltipDialog with a button that spawns a tree of menus, find the popup of the button.

Returns:undefined
hide(widget)
Defined by dijit/popup

Hide this popup widget (until it is ready to be shown). Initialization for widgets that will be used as popups

Also puts widget inside a wrapper DIV (if not already in one)

If popup widget needs to layout it should do so when it is made visible, and popup._onShow() is called.

Parameter Type Description
widget Widget
moveOffScreen(widget)
Defined by dijit/popup

Moves the popup widget off-screen. Do not use this method to hide popups when not in use, because that will create an accessibility issue: the offscreen popup is still in the tabbing order.

Parameter Type Description
widget Widget
Returns:undefined
open(args)
Defined by dijit/popup

Popup the widget at the specified position

Parameter Type Description
args Object

An object with the following properties:

  • popup (Widget):

    widget to display

  • parent (Widget):

    the button etc. that is displaying this popup

  • around (DomNode):

    DOM node (typically a button); place popup relative to this node. (Specify this or "x" and "y" parameters.)

  • x (Integer):

    Absolute horizontal position (in pixels) to place node at. (Specify this or "around" parameter.)

  • y (Integer):

    Absolute vertical position (in pixels) to place node at. (Specify this or "around" parameter.)

  • orient (Object|String):

    When the around parameter is specified, orient should be a list of positions to try, ex:

    [ "below", "above" ]

    For backwards compatibility it can also be an (ordered) hash of tuples of the form

    (around-node-corner, popup-node-corner), ex:

    { "BL": "TL", "TL": "BL" }

    where BL means "bottom left" and "TL" means "top left", etc.

    dijit/popup.open() tries to position the popup according to each specified position, in order, until the popup appears fully within the viewport.

    The default value is ["below", "above"]

    When an (x,y) position is specified rather than an around node, orient is either "R" or "L". R (for right) means that it tries to put the popup to the right of the mouse, specifically positioning the popup's top-right corner at the mouse position, and if that doesn't fit in the viewport, then it tries, in order, the bottom-right corner, the top left corner, and the top-right corner.

  • onCancel (Function):

    callback when user has canceled the popup by:

    1. hitting ESC or
    2. by using the popup widget's proprietary cancel mechanism (like a cancel button in a dialog); i.e. whenever popupWidget.onCancel() is called, args.onCancel is called
  • onClose (Function):

    callback whenever this popup is closed

  • onExecute (Function):

    callback when user "executed" on the popup/sub-popup by selecting a menu choice, etc. (top menu only)

  • padding ([object Value(type: object, value: undefined)]):

    adding a buffer around the opening position. This is only useful when around is not set.

  • maxHeight (Integer):

    The max height for the popup. Any popup taller than this will have scrollbars. Set to Infinity for no max height. Default is to limit height to available space in viewport, above or below the aroundNode or specified x/y position.

Returns:undefined

Examples

Example 1

opening at the mouse position

popup.open({popup: menuWidget, x: evt.pageX, y: evt.pageY});

Example 2

opening the widget as a dropdown

popup.open({parent: this, popup: menuWidget, around: this.domNode, onClose: function(){...}});

Note that whatever widget called dijit/popup.open() should also listen to its own _onBlur callback (fired from _base/focus.js) to know that focus has moved somewhere else and thus the popup should be closed.

Error in the documentation? Can’t find what you are looking for? Let us know!