Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!