Edit this page

up.form up:form:submit
DOM event

This event is emitted when a form is submitted through Unpoly.

The event is emitted on the element that caused the form submission. This is usually a submit button or a focused field. If the element is not known, the event is emitted on the <form> element.

When the form is being validated, this event is not emitted. Instead an up:form:validate event is emitted.

Changing render options

Listeners may inspect and manipulate render options for the coming fragment update.

The code below will use a custom transition when a form submission fails:

up.on('up:form:submit', function(event, form) {
  event.renderOptions.failTransition = 'shake'
})

Event properties

event.target Element

The element that caused the form submission.

event.params up.Params

The form parameters that will be send as the form's request payload.

Listeners may inspect and modify params before they are sent.

[event.submitButton] Element optional

The button used to submit the form.

If no button was pressed directly (e.g. the user pressed Enter inside a focused text field), this returns the first submit button.

event.renderOptions Object

An object with render options for the fragment update.

Listeners may inspect and modify these options.

event.preventDefault()

Prevents the form from being submitted.