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

107
Visualizações
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 Respostas
Responde à pergunta

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 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