sweetalert icon indicating copy to clipboard operation
sweetalert copied to clipboard

Control over buttons during ajax

Open donnysim opened this issue 8 years ago • 7 comments

Is there a way to disable or hide cancel, etc. buttons during ajax request?

donnysim avatar Oct 25 '17 10:10 donnysim

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?

t4t5 avatar Nov 01 '17 08:11 t4t5

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.

donnysim avatar Nov 16 '17 10:11 donnysim

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?

arispati avatar Jan 12 '18 10:01 arispati

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.

t4t5 avatar Feb 15 '18 11:02 t4t5

i need this feature too but anyway thank you @t4t5 for such great plugin

navotera avatar Feb 17 '18 03:02 navotera

i need this feature too

ondery avatar Jul 05 '20 21:07 ondery

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

sharkey11 avatar Aug 15 '20 13:08 sharkey11