Edit this page

up.event a[up-emit]
HTML selector

Emits the given event when this link is clicked.

When the emitted event's default' is prevented, the original click event's default is also prevented.

You may use this attribute to emit events when clicking on areas that are no hyperlinks, by setting it on an <a> element without a [href] attribute.

Example

This hyperlink will emit an user:select event when clicked:

<a href='/users/5'
  up-emit='user:select'
  up-emit-props='{ "id": 5, "firstName": "Alice" }'>
  Alice
</a>

<script>
  up.on('a', 'user:select', function(event) {
    console.log(event.firstName) // logs "Alice"
    event.preventDefault()       // will prevent the link from being followed
  })
</script>

Modifying attributes

up-emit

The type of the event to be emitted.

[up-emit-props='{}'] optional

The event properties, serialized as JSON.