Tengo un hipervínculo como este:
<a href="{{ route('courseRegistration', $item->cor_id) }}" class="btn btn-info" id="custombtn"> Register </a>Luego agregué esto para mostrar un mensaje de Sweetalert con los botones Sí y No :
$(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; }); }); Como puede ver, quiero decir: si el usuario hizo clic en el botón Sí , vaya a la ruta href y, si no, permanece en la página ( return false ).
Entonces, la pregunta es, ¿cómo puedo redirigir al usuario a href="{{ route('courseRegistration', $item->cor_id) }}" , si hace clic en el botón Sí ?
puede usar window.location.href = "YOURLINKHERE" para redirigir a otra página después de verificar si isConfirm.value está configurado (no tiene que verificar si es verdadero, ya que el botón cancelar no devuelve isConfirm.value)