Edit this page

up.Layer up.Layer.prototype.emit([target], eventType, [props])
Class method

Emits an event on this layer's element.

The value of up.layer.current will be set to the this layer while event listeners are running.

Example

let rootLayer = up.layer.root
let overlay = await up.layer.open()

rootLayer.on('foo', (event) => console.log('Listener called'))

rootLayer.emit('foo') // logs "Listener called"
overlay.emit('foo')   // listener is not called

Parameters

[target=this.element] ElementorjQuery optional

The element on which the event is triggered.

If omitted, the event will be emitted on the this layer's element.

eventType string

The event type, e.g. my:event.

[props={}] Object optional

A list of properties to become part of the event object that will be passed to listeners.

[props.log] stringorArray optional

A message to print to the log when the event is emitted.

Pass false to not log this event emission.

[props.target=this.element] ElementorjQuery optional

The element on which the event is triggered.

Alternatively the target element may be passed as the first argument.