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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742287066a4415508.html
评论列表(0条)