Laravel how to redirect back to boostrap modal dialog window

前端 未结 4 1438
时光取名叫无心
时光取名叫无心 2021-02-06 07:55

I want to return to my modal dialog edit form to show validation errors but using Redirect::back I just end up at the HTML page without the modal window.

I

4条回答
  •  时光说笑
    2021-02-06 08:31

    The only thing I could think of is setting something like this:

    `` 
    

    When the page is loaded by a get request, this value will be set to "", as Input::old('show') isn't set (well is but is set to ""). Then, when you post the form, change the value of this input to:

    $("input[name=show"]").val("yes");
    

    So that if/when the page redirects, the value of this hidden input will be set to "yes" instead of "". Then, handle that in Javascript:

    $(document).ready(function(){
      if($("input[name=show]").val() != "")){
        $('#modal_id').modal('show');
      }
    });
    

    Hope that makes sense!

提交回复
热议问题