Jquery 如何返回重定向到Laravel中的模态?
我有一个模式,当我的用户点击登录时会触发。Jquery 如何返回重定向到Laravel中的模态?,jquery,laravel,laravel-4,laravel-5,Jquery,Laravel,Laravel 4,Laravel 5,我有一个模式,当我的用户点击登录时会触发。 思维方式 如果身份验证失败,我想重新引导回到这个模式 考虑到这一点,我想重新导演: 回到我的主页 触发此模式 在那里闪现我的会话 HTML Btn 登录 模态 <!--Login Modal--> <div class="light-skin modal fade" id="loginModal" tabindex="-1" role="form" aria-hidden="true"> <div class
思维方式 如果身份验证失败,我想重新引导回到这个模式 考虑到这一点,我想重新导演:
- 回到我的主页
- 触发此模式
- 在那里闪现我的会话李>
HTML Btn
登录
模态
<!--Login Modal-->
<div class="light-skin modal fade" id="loginModal" tabindex="-1" role="form" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Login here</h4>
{{-- Session --}}
@include('layouts.session')
</div>
<div class="modal-body">
<form class="login-form" role="form" method="post" action="/">
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" placeholder="Enter Username" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Enter Password" required>
</div>
<button type="submit" class="btn btn-primary">Login</button>
{!! Form::token() !!}
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
没有什么是导火索。有人给我任何提示吗?多亏了@Tim Lewis和@Kryten为我指明了正确的方向 我相信有不止一种方法可以做到这一点,但这里我如何让我的工作
<?php $error = Session::get('error'); ?>
// If there is error, the modal will be trigger.
@if(!empty($error) )
<script>
$(function() {
$('#loginModal').modal('show');
});
</script>
@endif
//如果出现错误,将触发模式。
@如果(!empty($error))
$(函数(){
$('loginModal').modal('show');
});
@恩迪夫
示例:模式是否通过Javascript触发?如果是这样的话,你需要在页面加载时通过Javascript来完成。我可以看到2个选项:1。使用某种标志/会话变量重新加载页面,该变量指定应打开模式或2。通过
ajax
执行您的后端工作,并且永远不要实际关闭模式/重定向页面。
<?php $error = Session::get('error'); ?>
// If there is error, the modal will be trigger.
@if(!empty($error) )
<script>
$(function() {
$('#loginModal').modal('show');
});
</script>
@endif