up.emit([target], eventType, [props])
JavaScript function
Emits a custom event with the given name and properties.
The event will be dispatched on the document or on the given element.
You can listen to events of that type using
addEventListener()
or up.on().
Example
up.on('my:event', function(event) {
console.log(event.foo)
})
up.emit('my:event', { foo: 'bar' })
// Prints "bar" to the console
Event
[target=document]
eventType
required
The event type, e.g. my:event.
Type: string
[props={}]
optional
A list of properties to become part of the event object that will be passed to listeners.
Type: Object
Options
[props.layer]
optional
The layer on which to emit this event.
If this property is set, the event will be emitted on the layer's outmost element. Also up.layer.current will be set to the given layer while event listeners are running.
Type: up.Layer | string | number
[props.target=document]
[props.log]
Return value
The emitted event object.
Type: Event