I am currently utilizing sweetAlert2 and attempting to integrate bootstrap 4 for button styling by implementing the following properties:
buttonsStyling: false,
confirmButtonClass: 'btn btn-primary btn-lg',
cancelButtonClass: 'btn btn-lg'
The implementation is successful, but there is an issue with the appearance of the showLoaderOnConfirm
option when using those specified properties.
You can refer to the examples below:
Steps to replicate the issue:
- Enter a valid email;
- Click on Submit;
- Observe the loader style difference between the first (bootstrap styled) and second (default sweetAlert2 styled).
$(function() {
$('#button').click(() => {
swal({
title: 'Submit email to initiate ajax request',
input: 'email',
showCancelButton: true,
confirmButtonText: 'Submit',
showLoaderOnConfirm: true,
buttonsStyling: false,
confirmButtonClass: 'btn btn-primary btn-lg',
cancelButtonClass: 'btn btn-lg',
preConfirm: function(email) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
if (email === '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5622373d333816332e373b263a337835393b">[email protected]</a>') {
reject('This email is already taken.')
} else {
resolve()
}
}, 2000)
})
},
allowOutsideClick: false
}).then(function(email) {
swal({
type: 'success',
title: 'Ajax request completed!',
html: 'Submitted email: ' + email
})
}).catch(swal.noop)
});
$('#button1').click(() => {
swal({
title: 'Submit email to run ajax request',
input: 'email',
showCancelButton: true,
confirmButtonText: 'Submit',
showLoaderOnConfirm: true,
preConfirm: function(email) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
if (email === '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f3879298969db3968b929e839f96dd909c9e">[email protected]</a>') {
reject('This email is already taken.')
} else {
resolve()
}
}, 2000)
})
},
allowOutsideClick: false
}).then(function(email) {
swal({
type: 'success',
title: 'Ajax request finished!',
html: 'Submitted email: ' + email
})
}).catch(swal.noop)
});
});
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.4.2/sweetalert2.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.4.2/sweetalert2.min.css" />
</head>
<body>
<button id="button">Show (Bootstrap)</button>
<hr />
<button id="button1">Show (w/o bootstrap)</button>
</body>
</html>
The query at hand is: How can I maintain the default loader style while utilizing bootstrap or potentially customize the style for the showLoaderOnConfirm
option...