WinJS.UI.Toolbar constructor

Creates a new Toolbar.

Syntax

var toolbar = new WinJS.UI.Toolbar(element, options);

Parameters

  • element
    Type: Object

    The associated DOM element that hosts the Toolbar.

  • options
    Type: Object

    An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on".

Remarks

The ToolBar tries to measure itself at construction so it can determine which elements can be in the available space in the action area and which to place in the overflow area. But if it is unable to (like if it's contained within a parent element that is set to display:none), this can cause (A) things to appear to jump around when the ToolBar is first opened (since that triggers a measure that allows the ToolBar to properly layout and overflow commands) and (B) the window can resize to not re-layout or overflow ToolBar commands ever if there hasn’t been at least one successful measure already.

An easy way to mitigate this kind of layout problem is to call Toolbar.forceLayout() whenever the width of the ToolBar component, or its children, has changed — but the width of the window does not.

Requirements

Minimum WinJS version

WinJS 4.0

Namespace

WinJS.UI

See also

Toolbar