Created
January 18, 2018 11:21
-
-
Save srghma/8ba0ee9d07c20dd8c8b3550c9df3e9ef to your computer and use it in GitHub Desktop.
doAsyncOnSubmit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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