Как сохранить форму с содержимым с данными Jquery при нажатии на кнопку «Назад» с другой страницы - PullRequest
0 голосов
/ 06 мая 2019

Я не могу загрузить предыдущую форму / страницу при нажатии на кнопку на предыдущей странице.Я хочу сохранить все переменные формы и контент с данными.Я использовал history.go (-1), он сохраняет выпадающие значения, но не значения выбора ввода.По клику идентификатора вызывается страница профиля.На странице профиля кнопка «Назад» должна вести на предыдущую страницу со всем содержимым.

Ниже приведен фрагмент кода:

<script> 
    //Generates datatable 
    function runReport() { 
        var $form = $("#" + $('#formName').val()); 
        $.ajax({ 
            url : '/events', 
            type : 'post', 
            data : $form.serialize(), 
            success : function(response) { 
                $('#sometable').DataTable({ 
                    "info": false, 
                    "paging": true, 
                    "ordering": true, 
                    "stateSave": true, 
                }); 
            } 
        }); 
    } 

    //Calls profile page of customer 
    function callProfilePage(id, custid) { 
        var datTable = $("#table").DataTable(); 
        var info = datTable.page.info(); 
        var pageindex=info.page; 
        var href = '/profile?custid='+custid+'&id='+id+'&pageindex='+pageindex; window.open(href,"_self"); 
    } 
</script>
<div> //Calls function to generate datatable content <button id="runreport" value="runreport" name="action" type="button" class="btn btn-primary" onclick="runReport()">Run Report</button>
</div>
<div class="col-sm-12 px-0" id="sometable"> //Datatable thats generated on click of Run Report <table class="table table-striped table-bordered table-sm" id="potential-tamper-table" cellspacing="0">
        <thead class="thead-light">
            <tr>
                <th scope="col">Report Date</th>
                <th scope="col">ID</th>
                <th scope="col">Customer ID</th>
                <th scope="col">Date of Event</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>30/04/2019</td>
                <td>
                    <a onclick="callProfilePage(id,custid)"/>86332</td> // Call to another page <td>
                    <span>12652666</span>
                </td>
                <td>
                    <span>31/10/2018 </span>
                </td>
            </tr>
        </tbody>
    </table>
</div>
...