-
Notifications
You must be signed in to change notification settings - Fork 3
Forms
Kwasi Yonkopa edited this page May 5, 2020
·
5 revisions
If you've configured the selector for active forms, you can query the current active form via Dash.getActiveForm().
Example
const activeForm = Dash.getActiveForm();DashJS provides a simple API to handle form submission events. DashJS serializes all inputs with a name attribute and makes them available in the callback when a user submits a form. This is done via Dash.submit(). Note that this calls e.preventDefault() by default.
Syntax
Dash.submit(formId, callback(e, formdata, action) => {
// Initiate request here
}, inputArray);Parameters
formId: string
- The id of the form you're targeting
callback: Function
- Submit event callback
formdata: FormData
- A FormData object of all input elements with
nameattributes found in the form
action: string
- The value of the action attribute of the form element
inputArray: Array
- Array of the *names of required input fields