Skip to content

submit

submit is a DOM event that occurs whenever the form based on a form-connector webcomponent is submitted.

Event body

The submit body has a TFormConnectorSubmitEventDetail type which represents the details of the submitted form. It is optional so it might not exist.

Example

In this example we listen to submit event and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    document.addEventListener('submit', (event) => {
        const detail = event.detail;

        if (!detail) return;

        const { form, submitActionProps } = detail;

        console.log(form, 'has been submitted with following props:', submitActionProps);
    });
});