Let the platform do the work

Drawers

Overview

The drawer layout widget, located in ./clients/base/layouts/drawer/, is used to display a window of additional content to the user. This window can then be closed to display the content the user was previously viewing.

Methods

app.drawer.open(layoutDef, onClose)

The app.drawer.open(layoutDef, onClose) method displays a new content window over the current view.

Parameters

Name Required Description
layoutDef.layout yes The id of the layout to load.
layoutDef.context no

Additional data you would like to pass to the drawer. Data passed in can be retrieved from the view using:

this.context.get('<data key>');

Note: Be very careful about what you pass in as data to the drawer. As the data is passed in by reference, when the drawer is closed, the context is destroyed.

onClose no Optional callback handler for when the drawer is closed.

Example

app.drawer.open({
    layout: 'my-layout',
    context: {
        myData: data
    },
},
function() {
    //on close, throw an alert
    alert('Drawer closed.');
});

app.drawer.close(callbackOptions)

The app.drawer.close(callbackOptions) method dismisses the topmost drawer.

Parameters

Name Required Description
callbackOptions no Any parameters passed into the close method will be passed to the callback.
Standard Example
app.drawer.close();
Callback Example
//open drawer
app.drawer.open({
    layout: 'my-layout',
},
function(message1, message2) {
    alert(message1);
    alert(message2);
});

//close drawer
app.drawer.close('message 1', 'message 2');

app.drawer.load(options)

Loads a new layout into an existing drawer.

Parameters

Name Description
options.layout The id of the layout to load.

Example

app.drawer.load({
    layout: 'my-second-layout',
});

app.drawer.reset(triggerBefore)

The app.drawer.reset(triggerBefore) method destroys all drawers at once. By default, whenever the application is routed to another page, reset() is called.

Parameters

Name Required Description
triggerBefore no Determines whether to triggerBefore. Defaults to false.

Example

app.drawer.reset();

Topics