退出时弹出显示并返回查看

时间:2014-09-04 14:49:01

标签: laravel modal-dialog

在我的应用程序中,我有一个删除弹出窗口。问题是,当我点击删除弹出窗口时,我点击取消之后,当我退出页面并再次返回时,弹出窗口再次显示!我不知道为什么。

这是我的控制者,

public function deletePopup()
{
    $questionId = (Input::get('question_id'));
        Session::flash('popup', $questionId); 
        return Redirect::to('/');
}

我的观点,

 <form action={{ url("popupQuestion") }} method="post">


    <input type="text" class="Question_id hiden" name="question_id" value="<?php echo $question->question_id ?>" />

    <input style="margin-bottom: -8px;" type="submit" class="btn btn-danger boutton-delete" value="Supprimer">


</form>
  @if(Session::has('popup'))
    <script type="text/javascript">
        $(document).ready(function() {
            $('#myModal').modal();
        });
    </script>
   <!-- Modal -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content center">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title" id="myModalLabel">Suppression</h4>
          </div>
          <div class="modal-body">
           <h5> Attention, vous allez supprimer une question. cette action est irréversible</h5>
          </div>
          <div class="modal-footer ">

          <form action={{ url("deleteQuestion") }} method="post">

            <input type="text" class="hiden " name="question_id" value={{ Session::get('popup') }} />
             <input type="text" class="hiden " name="pop" value="1" }} />

            <input type="submit" class="btn btn-danger btn-ok" type="submit" value="OK" />
             <button type="button" class="btn btn-info close-btn" data-dismiss="modal">Annuller</button>
          </form>



          </div>
        </div>
      </div>
    </div>   
    @endif

2 个答案:

答案 0 :(得分:0)

在结束@if(Session::has)之前将其放在@endif的底部:

Session::forget('popup');

此外,Laravel有一个方便的通知包,可以提供更多的灵活性:
https://github.com/edvinaskrucas/notification

答案 1 :(得分:0)

App::after(function($request, $response)
{
    $response->headers->set('Cache-Control','nocache, no-store, max-age=0, must-revalidate');
    $response->headers->set('Pragma','no-cache');
    $response->headers->set('Expires','Fri, 01 Jan 1990 00:00:00 GMT');
})

尝试将此代码放在app文件夹中的routes.php文件中。它将清除缓存。缓存可能是问题。