Skip to content

Instantly share code, notes, and snippets.

@srghma
Created January 18, 2018 11:21
Show Gist options
  • Save srghma/8ba0ee9d07c20dd8c8b3550c9df3e9ef to your computer and use it in GitHub Desktop.
Save srghma/8ba0ee9d07c20dd8c8b3550c9df3e9ef to your computer and use it in GitHub Desktop.
doAsyncOnSubmit
function doAsyncOnSubmit(form, asyncFn) {
const onSubmitFunction = async function(e) {
e.preventDefault()
form.off('submit', onSubmitFunction)
const doSubmit = await asyncFn()
if (doSubmit) {
form.submit()
}
}
form.on('submit', onSubmitFunction)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment