---
name: "up.Layer.prototype.emit"
area: "API"
kind: "Instance method"
parent: "up.Layer class"
url: "https://unpoly.com/api/up.Layer.prototype.emit"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.Layer class](https://unpoly.com/api/up.Layer.md)</nav>

# up.Layer.prototype.emit(eventType, [props])

[Emits](https://unpoly.com/api/up.emit.md) an event on [this layer's element](https://unpoly.com/api/up.Layer.prototype.element.md).

The value of [up.layer.current](https://unpoly.com/api/up.layer.current.md) will be set to this layer while event listeners are running.

<nav aria-label="Contents">

#### Contents

- [Example](#example)
- [Parameters](#parameters)
- [Return value](#return-value)

</nav>

## Example {#example}

```js
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 {#parameters}

### eventType {#eventType}

(required)

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

Type: string

### [props={}] {#props}

(optional)

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

Type: [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects)

### [props.log] (Experimental) {#props.log}

(optional)

A message to print to the [log](https://unpoly.com/api/up.log.md) when the event is emitted.

Pass `false` to not log this event emission.

Type: string | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)

---

## Return value {#return-value}

The emitted event object.

Type: [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event)

