admin管理员组文章数量:1335664
Flash message stays in there and can't close by itself and button close. I use bootstrap and js for build flash message. This my code.
Controller, i put before redirect line.
Session::flash('flash_message', 'It has been saved!');
also, i have written use Session
on Controller.
I made flash_message.blase.php
@if(Session::has('flash_message'))
<div class="alert alert-success {{ Session::has('penting') ? 'alert-important' : '' }}">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{{ Session::get('flash_message') }}
</div>
@endif
flash_message.blade.php has been included on index.
This the js code:
$('div.alert').not('.alert-important').delay(3000).slideUp(300);
js code has been written as script on my main template.
Why can't those work? How to fix it?
Flash message stays in there and can't close by itself and button close. I use bootstrap and js for build flash message. This my code.
Controller, i put before redirect line.
Session::flash('flash_message', 'It has been saved!');
also, i have written use Session
on Controller.
I made flash_message.blase.php
@if(Session::has('flash_message'))
<div class="alert alert-success {{ Session::has('penting') ? 'alert-important' : '' }}">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{{ Session::get('flash_message') }}
</div>
@endif
flash_message.blade.php has been included on index.
This the js code:
$('div.alert').not('.alert-important').delay(3000).slideUp(300);
js code has been written as script on my main template.
Why can't those work? How to fix it?
Share Improve this question asked Jul 12, 2018 at 3:07 Kyera NunaKyera Nuna 451 silver badge11 bronze badges 6- So the alert shows up, but doesn't disappear when you ckick the button, is that it? – Mav Commented Jul 12, 2018 at 3:10
- Yeah, That is right. What happens? How do make it work? – Kyera Nuna Commented Jul 12, 2018 at 3:11
- Are you loading the bootstrap javascript plugin? See: getbootstrap./docs/4.0/ponents/alerts/#dismissing – Mike Commented Jul 12, 2018 at 3:40
- I've tried a few possibilities, it's still no change. still can't close. – Kyera Nuna Commented Jul 12, 2018 at 4:20
- I pretty sure that you did not load bootstrap javascript plugin. Check your page in using developer tool, maybe some error logged in your console. – Ts8060 Commented Jul 12, 2018 at 4:23
2 Answers
Reset to default 7Try this
@if (session()->has('success'))
<div class="alert alert-dismissable alert-success">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<strong>
{!! session()->get('success') !!}
</strong>
</div>
@endif
This is what I use, without any issues.
@if(isset($errors))
@if(count($errors) >0 )
@foreach($errors->all() as $error)
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
{{$error}}
</div>
@endforeach
@endif
@endif
@if(session('success'))
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
{{session('success')}}
</div>
@endif
@if(session('error'))
<div class="alert alert-error alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
{{session('error')}}
</div>
@endif
本文标签:
版权声明:本文标题:javascript - Laravel flash message can't close using close button and can't close by itself in a while - Stack O 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742287065a2447115.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论