1
A
回答
2
控制器的动作会是这样的..
//use Illuminate\Http\Request;
public function flashTest(Request $request){
//see explanation for following line at very end
$request->session()->forget('flash_notification');
//Flash::success('this is an alert message'); //if you want to show alert message
Flash::overlay('Modal Message');
return view('yourview');
}
鉴于
<head>
<!-- Bootstrap css-->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
<!--if it's not an overlay, show flash message-->
@if (!Session::has('flash_notification.overlay'))
<div class="alert alert-{{ Session::get('flash_notification.level') }}">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{{ Session::get('flash_notification.message') }}
</div>
@else
<!--perform your overlay action here. For now i am showing a model-->
<script type="text/javascript">
$(document).ready(function(){
$('#myModal').modal('show');
});
</script>
<!-- bootstrap Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">{{ Session::get('flash_notification.title') }}</h4>
</div>
<div class="modal-body">
<p>{{ Session::get('flash_notification.message') }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
@endif
<!-- other code -->
<!-- bootstrap js -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</body>
OR
,如果你仅仅只想用这个包; 运行命令php artisan vendor:publish
在config/app.php中添加代码后,如laracast/flash中所述。
这将在“/ vendor/laracasts/flash/src/views /”目录中添加两个包视图。在这里您可以找到默认视图(您可以自定义它们)。
现在在你的视图文件只需添加
<body>
@include('flash::message')<!-- this line is important -->
<!-- bootstrap js -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<!-- This is only necessary if you do Flash::overlay('...') -->
<script>
$('#flash-overlay-modal').modal();
</script>
</body>
解释$request->session()->forget('flash_notification');
不知这个包是保留覆盖会话变量的键。即如果您首先显示重叠信息并且下次要显示Flash信息,则Flash信息也会显示为重叠。此行被添加以防止这种行为。请参阅laravel session。
也看看这个bootstrap overlay
相关问题
- 1. 如何在laravel 5.2
- 2. 我如何laravel 5.2
- 3. Laravel 5.2,如何从
- 4. 如何在Laravel 5.2
- 5. 如何在Laravel 5.2
- 6. 如何使用laravel 5.2
- 7. 如何使用Traits - Laravel 5.2
- 8. 如何获得在Laravel 5.2
- 9. 如何Laravel 5.2使用JQuery
- 10. 如何通过laravel 5.3到laravel 5.2
- 11. user auth Laravel 5.2
- 12. Laravel 5.2 datepicker
- 13. 密码laravel 5.2
- 14. laravel 5.2 - 与和
- 15. Selenium和Laravel 5.2
- 16. Laravel 5.2 Eloquent
- 17. Laravel 5.2 HTTPNOTFOUNDEXCEPTION
- 18. Laravel 5.2:在WhereHas
- 19. 关于Laravel 5.2
- 20. 使用Laravel 5.2
- 21. 在laravel 5.2
- 22. Laravel 5.2 +哎呦
- 23. Laravel 5.2 - 注册
- 24. Laravel 5.2 NotFoundHttpException
- 25. NotFoundHttpException PHP Laravel 5.2
- 26. Laravel 5.2 TokenMismatchException
- 27. 改变Laravel 5.2
- 28. Laravel 5.2 ERR_EMPTY_RESPONSE
- 29. Group by Laravel 5.2
- 30. Laravel 5.2 RefectionException
TY为你的答案,但我想'叠加'。使用提供的代码,仅显示闪烁警报。 –
仍然无法正常工作。 –
我已经测试过上面的代码,它的工作正常。向我们展示您的代码;你是如何做的,并提及是否有任何错误消息。 – SJB