Open Bootstrap Modal on history.go(-1) in onClick
<p>I have a bootstrap modal that needs to be opened when the user would want to go back to the previous page. Basically the first step in the process is that a user would click a button and a modal will popup and then after entering values in the modal, the user would then want to proceed to the next step where another modal will appear to basically confirm what the user has entered on the previous modal. If it happens that the user would want to change his/her answer, it can go back to the previous page and then update his/her answer. <strong><em>The problem in my code is that it can go back to the previous page but the modal isn't opening.</em></strong></p>

<p>HTML CODE ON THE FIRST PROCESS (FIRST MODAL):</p>

<pre><code>&lt;div class="modal fade bs-example-modal-lg" id="modal_insert" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" &gt;
&lt;div class="modal-dialog modal-lg"&gt;
    &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
            &lt;button type="button" class="close" data-dismiss="modal"&gt;
                &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
                &lt;span class="sr-only"&gt;Close&lt;/span&gt;
            &lt;/button&gt;
        &lt;h4 class="modal-title" id="myModalLabel"&gt;Update Hearing Details&lt;/h4&gt;
        &lt;/div&gt;
            &lt;form id="update_memo" class="form-horizontal form-label-left calender" name = "update_memo" enctype="multipart/form-data" method="post" role="form" novalidate&gt;
                &lt;div class="modal-body"&gt;
                    &lt;div class="d item form-group"&gt;
                    &lt;label class="col-sm-2 control-label"&gt;Hearing Number&lt;/label&gt;
                        &lt;div class="col-sm-8"&gt;
                            &lt;input type="number" class="form-control" id="hearing_number" name="hearing_number" readonly="readonly"/&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                        &lt;div class="d item form-group"&gt;
                            &lt;label class="col-sm-2 control-label"&gt;Attendance&lt;span class="required"&gt;*&lt;/span&gt; &lt;/label&gt;
                            &lt;div class="col-sm-8" style = "margin-top: 7px;"&gt;

                                &lt;input type="radio" id = "both_attendance"  name="attendance" value="2" checked &gt; Both Parties Showed Up &lt;br /&gt;
                                &lt;input type="radio" id = "resp_attendance" name="attendance" value="0" &gt; Respondent Did Not Show Up &lt;br /&gt;
                                &lt;input type="radio" id = "comp_attendance"  name="attendance" value="1" &gt; Complainant Did Not Show Up &lt;br /&gt;

                            &lt;/div&gt;
                        &lt;/div&gt;
                        &lt;div class="m item form-group"&gt;
                            &lt;label class="col-sm-2 control-label"&gt;Memo &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
                            &lt;div class="col-sm-8"&gt;
                                &lt;textarea rows="4" class="form-control" id="memo" name="memo" required="required"/&gt;&lt;/textarea&gt;
                            &lt;/div&gt;
                        &lt;/div&gt;

                &lt;/div&gt;
                &lt;div class="modal-footer" style="margin:0;"&gt;
                    &lt;button type="button" class="btn btn-default" data-dismiss="modal" style="margin-top: 4px;"&gt;Close&lt;/button&gt;
                    &lt;button id="send" type="submit" class="btn btn-success" name="update_memo"&gt;Save Record&lt;/button&gt;
                &lt;/div&gt;
            &lt;/form&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>2ND MODAL: </p>

<pre><code>&lt;?php
include 'config.php';
if(isset($_POST['update_memo'])){
    $id = isset($_GET['id'])? $_GET['id'] : "";
    $hearingNo = $_POST['hearing_number'];
    $memo = $_POST['memo'];
    $attendance = $_POST['attendance'];

 ?&gt;

&lt;div class="modal fade bs-example-modal-lg" id="modal_confirm" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" &gt;
    &lt;div class="modal-dialog modal-lg"&gt;
        &lt;div class="modal-content"&gt;
            &lt;div class="modal-header" style="background-color: #f0ad4e; color:#fff"&gt;
                &lt;h4 class="modal-title" id="myModalLabel"&gt;Memo Confirmation &lt;/h4&gt;
            &lt;/div&gt;
            &lt;form id="update_memo" class="form-horizontal form-label-left calender" name = "update_memo" enctype="multipart/form-data" method="post" role="form" novalidate&gt;
                &lt;div class="modal-body" style="display:none"&gt;
                    &lt;div class="d item form-group"&gt;
                        &lt;label class="col-sm-2 control-label"&gt;Hearing Number&lt;/label&gt;
                        &lt;div class="col-sm-8"&gt;
                            &lt;input type="number" class="form-control" id="h_num" name = "h_num" value="&lt;?php echo $hearingNo; ?&gt;" readonly="readonly"/&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;              
                &lt;div class=" item form-group"&gt;
                    &lt;label class="control-label col-md-5 col-sm-5 col-xs-12" style="left:20px;" &gt;&lt;h4&gt;&lt;b&gt;Do you wish to continue with the memo?&lt;/b&gt;&lt;/h4&gt;&lt;/label&gt;
                    &lt;div class="col-sm-8"&gt;&lt;/div&gt;
                &lt;/div&gt;
                &lt;div class=" item form-group"&gt;
                    &lt;label class="control-label col-md-1 col-sm-1 col-xs-12"&gt;&lt;/label&gt;
                    &lt;div class="col-sm-10"&gt;
                        &lt;blockquote style="font-size: 18px; right: 30px; text-align: justify"&gt;&lt;?php echo $memo; ?&gt;&lt;/blockquote&gt;
                    &lt;/div&gt;
                &lt;/div&gt;

                &lt;div class="modal-footer" style="margin:0;"&gt;
                    &lt;button type="button" style="margin-top: 6px;" class="btn btn-dark" name="return" onClick="javascript: history.go(-1); showModal(); ";&gt;&lt;i class="fa fa-arrow-circle-o-left m-right"&gt;&lt;/i&gt;  Return&lt;/button&gt;
                    &lt;button id="send" type="submit" class="btn btn-success" name="memo_confirm"&gt;&lt;i class="fa fa-check m-right"&gt;&lt;/i&gt;  Proceed&lt;/button&gt;
                &lt;/div&gt;
 &lt;?php

  }
  ?&gt;
            &lt;/form&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>Javascript code to call the first modal: (it is like this because when the user clicks this it passes a value in data-id; this is working)</p>

<pre><code>$(document).ready(function(){
    $('#modal_insert').on('show.bs.modal', function (e) {
        var id = $(e.relatedTarget).data('id');
        //alert(id);
        $("#hearing_number").val(id);
});
</code></pre>

<p>2ND MODAL:</p>

<pre><code>$(document).ready(function(){
    $('#modal_confirm').modal('show');
});
</code></pre>

<p>FUNCTION THAT TRIES TO CALL THE MODAL AFTER HISTORY.GO(-1)
     </p>

<pre><code>        //not working
        $(document).ready(function(){
            function showModal() {  
            $('#modal_insert').modal('show');
            }
        });
        //alert("OPEN"); 

&lt;/script&gt;
</code></pre>

<p>How can I achieve this? Which part of my code should be changed or tweaked? Thank you so much in advance for your help!!! </p>