sweetalert
sweetalert copied to clipboard
Control over buttons during ajax
Is there a way to disable or hide cancel, etc. buttons during ajax request?
The buttons should automatically be disabled and show a spinner if you use closeModal: true like in this example. Are you looking for something else?
Sorry for the late very reply, it does show loading and works fine when it's 1 button, but I have 2 buttons - Cancel and Confirm, if you click Confirm, it shows loading, but Cancel is still available when it should be disabled or hidden while loading.
I've the same issue with @donnysim , i've 2 buttons (cancel and confirm). this is my code:
swal({
title: 'Are you sure?',
text: 'You can\'t restore this data!',
icon: 'warning',
buttons: {
cancel: {
text: 'Cancel',
visible: true,
},
confirm: {
text: 'Delete',
closeModal: false,
}
},
dangerMode: true,
closeOnClickOutside: false,
}).then((isDelete) => {
if (isDelete) {
setTimeout(function(){
alert('deleted');
}, 5000);
}
});
the cancel button still clickable when loading state. how to solved this issue?
That's a good point. Hmm. I suppose the question is whether the modal's state should be "locked" in some situations.
I can think of ugly ways to get around this issue, but not sure what the best path forward is. We might want to attach an onClick function to the button options that the user can customise.
i need this feature too but anyway thank you @t4t5 for such great plugin
i need this feature too
Me too -- really badly. Defeats the purpose of having a cancel button during the ajax request. Either need to hide the button or be able to actually cancel the loading ajax function. Preferably just hide the button