Submit forms in dialogs
If you’re using a <form>
element inside a <dialog>
element, you might want to consider setting its method
attribute to dialog
.
This will cause the dialog to close automatically on form submission and set the value of the submit button to dialog.returnValue
. It will not actually submit the form though.
More details:
- https://webkit.org/blog/12209/introducing-the-dialog-element/
- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-method
I learned about this from Dominik Reitz ner at the Svelte Vienna Meetup.