Edit this page

up.layer up:layer:open
DOM event

This event is emitted before an overlay is opened.

At emission time the overlay is not yet part of the layer stack. The overlays elements have yet been placed in the DOM. Listeners may prevent this event to prevent the overlay from opening.

The event is emitted on the document.

Opening overlays

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
required

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
required

The link element that is opening the overlay.

event.preventDefault()
required

Prevents this overlay from opening.

Programmatic callers will reject with an up.AbortError.