Skip to content

Instantly share code, notes, and snippets.

@jack2jm
Created January 31, 2023 05:17
Show Gist options
  • Select an option

  • Save jack2jm/7123632839ed596f538c176cb6953e24 to your computer and use it in GitHub Desktop.

Select an option

Save jack2jm/7123632839ed596f538c176cb6953e24 to your computer and use it in GitHub Desktop.
1. Load css/js
<link rel="stylesheet" href="https://cdn.jsdelivr.net/sweetalert2/5.3.8/sweetalert2.css"/>
<script src="https://cdn.jsdelivr.net/sweetalert2/5.3.8/sweetalert2.js"></script>
2. Define function
const showLoading = function() {
swal({
title: '',
text: '<b>Be patient.</b><br/>This might take a few moments to load chatbot questions.',
allowEscapeKey: false,
allowOutsideClick: false,
//timer: 4500,
onOpen: () => {
swal.showLoading();
}
})
};
function closeSwalWhilePageLoaded(){
setTimeout(() => {
swal.close();
}, 500);
}
3. Call show loading
showLoading();
4. Call function to close loading
closeSwalWhilePageLoaded();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment