0

I am working on a project in Laravel-5.8,

When the user clicks on the href it posts all respondents:

Controller:

public function submit_all_respondents(){
     ...
  Notification::route('mail', $details['employee_respondent_email'])
                                ->notify(new \App\Notifications\RespondentSubmit($details));
  Session::flash('success', 'Email sent to respondents successfully');
  return redirect()->back();
}  

View

<a href ="{{ route('post.respondent.all')}}" class="btn btn-primary float-left"><i class="fas fa-arrow-right"></i> Post All Respondents</a>   

After just a single click, I want the href to be disabled and becomes "Processng ..." until it is done.

How do I achieve this

3
  • 2
    When the anchor tag link is clicked, you go to a new page. Commented Oct 26, 2020 at 13:16
  • Until what is done? With what is shown all that happens is you load that new route when clicking on that <a>. Commented Oct 26, 2020 at 13:25
  • @charlietfi - I have added the controller Commented Oct 26, 2020 at 13:31

2 Answers 2

1

You can disable the href using CSS. If you add CSS style pointer-events: none;, that selector won't accept any pointer events. (So same as disabled.)

So it's good to create a new class called .processing and add it to selector when the user clicks it.

function processing(event) {
  event.target.className += " processing";
}
.processing {
  pointer-events: none;
  opacity: 0.5;
}
<a href ="#" class="btn btn-primary float-left" onclick="processing(event)"><i class="fas fa-arrow-right"></i> Post All Respondents</a>

Sign up to request clarification or add additional context in comments.

Comments

0

Simple solution :

$(...).click(function(e) {
    if ($(this).is(':disabled')) {
        e.preventDefault();
    }

    $(this).prop('disabled', true)
        .html('<i class="fas fa-arrow-right"></i> Processng ...');
});

5 Comments

I used this: <script type="text/javascript"> $(#review_comment_btn-submit).click(function() { $(this).prop('disabled', true) .html('<i class="fas fa-arrow-right"></i> Processng ...'); }); </script> but didn't work id=review_comment_btn-submit
You're missing quotes arround #review_comment_btn-submit in your sample.
It changes to processing... but did not disable the href. It still allows users to be able to click
It changes to processing... but did not disable the href. It still allows users to be able to click on href
Still not disabled

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.