Created
September 6, 2017 14:30
-
-
Save t4t5/730b44e10c7b56b26e86c1db534827e6 to your computer and use it in GitHub Desktop.
Using async with SweetAlert
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
const deleteFile = async () => { | |
// Wait for the user to press a button... | |
const shouldDelete = await swal("Delete file?", "Are you sure that you want to delete this file?", "warning"); | |
if (shouldDelete) { | |
// Code to actually delete file goes here | |
swal("Poof!", "Your file has been deleted!", "success"); | |
} | |
} |
async largeFileAlert (file) {
try {
const alert = await Swal.fire({
title: 'Are you sure?',
text: `Warning, your image file is too heavy for this specific format.`,
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, Keep it!',
cancelButtonText: 'No, Cancel it'
});
return !!(alert.value && alert.value === true);
} catch (e) {
console.log('error:', e);
return false;
}
},
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
algun ejemplo para hacer funcionar
const {value: text} = await swal({
input: 'textarea',
inputPlaceholder: 'Type your message here',
showCancelButton: true
})
if (text) {
swal(text)
}