Edit this page

up.layer up.layer.ask(options)
JavaScript function

Opens an overlay and returns a promise for its acceptance.

It's useful to think of overlays as promises which may either be fulfilled (accepted) or rejected (dismissed).

Opening overlays

Example

Instead of using up.layer.open() and passing callbacks, you may use up.layer.ask(). up.layer.ask() returns a promise for the acceptance value, which you can await:

let user = await up.layer.ask({ url: '/users/new' })
console.log("New user is " + user)

To handle the case that the overlay wasn't completed successful, you can catch the rejected promise reason:

try {
  let user = await up.layer.ask({ url: '/users/new' })
  console.log("New user is",  user)
} catch (reason) {
  console.error("Could not register:", reason)
}

Parameters

options
required

See options for up.layer.open().


Return value

A promise that settles when the overlay closes.

When the overlay was accepted, the promise will fulfill with the overlay's acceptance value.

When the overlay was dismissed, the promise will reject with the overlay's dismissal reason.