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

105
Vistas
How to set Yes & No button actions on hyperlink in SweetAlert

I have a hyperlink like this:

<a href="{{ route('courseRegistration', $item->cor_id) }}" class="btn btn-info" id="custombtn">
     Register
</a>

Then I added this to show a Sweetalert message with Yes and No buttons:

$(document).on('click', '#custombtn', function(e) {
    e.preventDefault();
    let form = $(this).parents('form');
    swal(
    {
        title: "Alert!",
        text: "You have an active Wallet, do you wish to pay the price with the active Wallet?",
        type: "warning",
        allowEscapeKey: false,
        allowOutsideClick: false,
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "Yes",
        cancelButtonText: "No",
        showLoaderOnConfirm: true,
        closeOnConfirm: false
    }).then((isConfirm) => {
        if (isConfirm.value === true) {
            // go to the href route
        }
        return false;
    });
});

As you can see I want to say: if user clicked on the Yes button, goto href route and if not, stays on the page (return false).

So the question is, how can I redirect user to href="{{ route('courseRegistration', $item->cor_id) }}", if he clicks on Yes button?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you can use window.location.href = "YOURLINKHERE" to redirect to another page after checking if isConfirm.value is set (you dont have to check for true, since the cancel Button doesn't return isConfirm.value)

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