javascript - fade out animation for session flash message - Stack Overflow

Is there any way to set up a flash message session for laravel?Which means when I click the button to

Is there any way to set up a flash message session for laravel? Which means when I click the button to add or delete item(s), the flash messages are displayed. But Is there any way to fade out?

in view file I put the code below:-

  <script>
      $(document).ready(function(){
          setTimeout(function() {
              $('#msg').fadeOut('fast');
          }, 30000);
      });
  </script>

  @if (session('status'))
      <div class="alert alert-success">
          <p class="msg"> {{ session('status') }}</p>
      </div>
  @endif

Controller file which I used for return the message.

return back()->with('status', $pro->pro_name . ' add to cart successfully');

Is there any way to set up a flash message session for laravel? Which means when I click the button to add or delete item(s), the flash messages are displayed. But Is there any way to fade out?

in view file I put the code below:-

  <script>
      $(document).ready(function(){
          setTimeout(function() {
              $('#msg').fadeOut('fast');
          }, 30000);
      });
  </script>

  @if (session('status'))
      <div class="alert alert-success">
          <p class="msg"> {{ session('status') }}</p>
      </div>
  @endif

Controller file which I used for return the message.

return back()->with('status', $pro->pro_name . ' add to cart successfully');
Share Improve this question edited Oct 6, 2019 at 17:06 Salim Djerbouh 11.1k6 gold badges33 silver badges64 bronze badges asked Nov 7, 2018 at 6:51 lun7codelun7code 1992 gold badges4 silver badges15 bronze badges 2
  • Clicking a button happens client-side, flash messages are stored serverside. Unless you want the whole page to refresh when you click the button I suggest just looking into alternative solutions. If it's just a "toast" (or growl) message you want then take a look at bootstrap-notify.remabledesigns. – apokryfos Commented Nov 7, 2018 at 7:16
  • still not work, could you check my post again, i just edited it. – lun7code Commented Nov 7, 2018 at 8:18
Add a ment  | 

4 Answers 4

Reset to default 2

Try this

<script>
      $(document).ready(function(){
    $('.alert-success').fadeIn().delay(10000).fadeOut();
      });
  </script>

  @if (session('status'))
      <div class="alert alert-success">
          <p class="msg"> {{ session('status') }}</p>
      </div>
  @endif

Hope this will help you

$(window).load(function(){
   setTimeout(function(){ $('.alert-success').fadeOut() }, 5000);
});

This div will fade out after 5 seconds.

@if (session('status'))
  <div class="alert alert-success">
      <p class="msg"> {{ session('status') }}</p>
  </div>

@endif

Try using toastr, it is a Javascript library for non-blocking notifications.

I know it's too late, but you could try this:

$(document).ready(function(){
     if (('.alert').is(':visible')) { 
        setTimeout(() => {
           $('.alert').fadeOut('slow')
        }, 3000);
     }
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745111840a4611895.html

相关推荐

  • javascript - fade out animation for session flash message - Stack Overflow

    Is there any way to set up a flash message session for laravel?Which means when I click the button to

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信