Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda