dscrn1974
2018-11-07 06:51
浏览 63
已采纳

laravel问题:淡出会话flash消息

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 anyway 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');
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dongqixian8474 2018-11-07 07:07
    已采纳

    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
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dongle7882 2018-11-07 07:02

    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

    评论
    解决 无用
    打赏 举报
  • doulan6150 2019-08-07 04:33

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

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题