Edit this page

up.layer up:layer:open
DOM event

This event is emitted before an overlay is opened.

The overlay is not yet part of the layer stack and has not yet been placed in the DOM. Listeners may prevent this event to prevent the overlay from opening.

The event is emitted on the document.

Changing layer options

Listeners may inspect and manipulate options for the overlay that is about to open.

For example, to give overlays the CSS class .warning if the initial URL contains the word "confirm":

up.on('up:layer:open', function(event) {
  if (event.layerOptions.url.includes('confirm')) {
    event.layerOptions.class = 'warning'
  }
})

Event properties

event.layerOptions Object

Options for the overlay that is about to open.

Listeners may inspect and change the options. All options for up.layer.open() may be used.

event.origin Element

The link element that is opening the overlay.

event.preventDefault()

Prevents this overlay from opening.

Programmatic callers will reject with an up.AbortError.