Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
Add loading to sweetalert when send request to livewire

I wrote my code below and it works correctly and the answer is received correctly. But the problem is that when the confirm button is clicked, the sweetalert closes

I want the sweetalert not to be closed until the request is fully executed and the loading button to be displayed. I saw a lot of questions about this but they were related to ajax and I could not create them for livewire

document.addEventListener('DOMContentLoaded', function () {
    $('.eg-swal-av3').on("click", function (e) {
        Swal.fire({
            title: 'title',
            text: "content",
            icon: 'info',
            showCancelButton: true,
            confirmButtonText: 'بله ایجاد کن',
            cancelButtonText : 'لغو',
        }).then(function (result) {
            if (result.value) {
                @this.call('createRequest');
            }
        });
        e.preventDefault();
    });
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You're looking for the preConfirm property, which accepts a callback. This is where you would run the call to your createRequest.

I would also add a allowOutsideClick to be true when loading, so that the alert is visible throughout the request.

Swal.fire({
    title: 'title',
    text: "content",
    icon: 'info',
    showCancelButton: true,
    confirmButtonText: 'بله ایجاد کن',
    cancelButtonText : 'لغو',
    allowOutsideClick: () => !Swal.isLoading(),
    preConfirm: function(result) {
        if (result) {
            return @this.call('createRequest').then(() => {
                Swal.fire('Loading complete');
            });
        }
    },
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda