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

219
Views
Making text disappear using laravel livewire by timing out the flash message

I've written some code using laravel livewire that makes a modal appear whenever a user successfully subscribes or volunteers to join my website. I've tried writing some code that delays the modal, but now it's just making my code slower instead of making some text disappear after a few seconds. Here's the code that I've written on my blade file.

  <div wire:loading.delay.short class="bg-white shadow" style="border-radius: 30px">
                @if (session()->has('subscription_message'))
                   @include('livewire.frontend.subscribe.success') 
                @endif
   </div>

I want the subscription_message to disappear and I've also written the subscription_message on another blade file.

<div wire:loading id="modal" class="alert alert-success" role="alert">
<h6 class="alert-heading">Thank you for your Subscription!🤗</h6>
<p>{{ session('subscription_message') }}<i class="fa fa-check"></i></p>
<p class="mb-0">Kind Regards,<br>
    {!! 'Ben's Team' !!}
</p>
</div>

Here's the livewire component that controlls all the code on those two blade files.

 public function save()
{
    $this->validateForm();
    Subscription::create([
        'name' => $this->name,
        'email' => $this->email
    ]);
    $name = $this->name;
    $email = $this->email;

    $message = "Dear $name ! Thank you for subscribing with Us, Please check your email:($email) for more information.";
    $this->resetInput();

    // Sent Welcome email to subscriber
    Mail::to($email)->send(new WelcomeSubscriberNotification());

    session()->flash('subscription_message',$message);
}

I don't know how to timeout the flash message that appears after a user has subscribed. Can any assist me on a way to solve this problem? I want to use livewire, but if that doesn't work, I'm willing to use either Jquery or Javascript.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I've got it. On the blade file which shows the success message after clicking the submit button, I just added the following js code.

Blade file


<div id="modal" class="alert alert-success" role="alert">
<h6 class="alert-heading">Thank you for your Subscription!🤗</h6>
<p>{{ session('subscription_message') }}<i class="fa fa-check"></i></p>
<p class="mb-0">Kind Regards,<br>
    {!! 'Ben's Team' !!}
</p>
</div>

JS Code

var timeout = 3000; // in miliseconds (3*1000)
$('.alert').delay(timeout).fadeOut(300);</script>
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!