Submits a form via AJAX and updates a page fragment with the response.
Instead of loading a new page, the form is submitted via AJAX. The response is parsed for a CSS selector and the matching elements will replace corresponding elements on the current page.
The unobtrusive variant of this is the [up-submit]
selector.
See its documentation to learn how form submissions work in Unpoly.
Submitting a form is considered navigation.
Emits the event up:form:submit
.
up.submit('form.new-user', { target: '.main' })
The form to submit.
If the argument points to an element that is not a form, Unpoly will search its ancestors for the closest form.
Render options that should be used for submitting the form.
Unpoly will parse render options from the given form's attributes
like [up-target]
or [up-transition]
. See [up-submit]
for a list
of supported attributes.
You may pass this additional options
object to supplement or override
options parsed from the form attributes.
Whether this fragment update is considered navigation.
Setting this to false
will disable most defaults.
The target selector to update when the server responds with an error code.
Defaults to the form element itself.
Whether to disable form controls while the form is submitting.
The element that triggered the form submission.
This defaults to the first applicable:
Enter
inside a text field)<form>
elementAdditional Form parameters that should be sent as the request's query string or payload.
The given value will be added to params parsed from the form's input field.
The submit button used to submit the form.
By default the form's first submit button will be assumed.
Pass { submitButton: false }
to not assume any submit button.
A promise that fulfills with an up.RenderResult
once the server response was loaded and rendered.