Bootstrap Model表显示旧数据(Bootstrap 3.3.4)

时间:2015-08-09 11:01:49

标签: jquery asp.net-mvc twitter-bootstrap-3

正在使用Bootstrap 3.3.4 ...

当我点击EDIT按钮时,我将使用bootstrap模式显示表格

<button id="editbutton" name="editbutton" onclick="editappealrecords(this)" type="button" class="btn btn-primary">Edit</button>

<div class="row row2 panel panel-default panel-default2">
    <div class="panel-heading panel-heading2 text-left">
        <h3 class="panel-title panel-txt-weight">IV. Required Attachment: </h3>
    </div>

    <div class="row">
        <div class="col-xs-12 col-sm-12">
            <div class="form-group">
                <table class="table table-bordered table-bordered1" id="datatableedit">
                    <button type="button" class="btn btn-primary btn-sm login-align" name="name" onclick="addRowedit('dataTable')" >Add one more attachments</button>

                    <thead id="tb-head-attach">
                        <tr>
                        <th>Description</th>
                        <th>Browse File</th>
                        <th>Action</th>
                        </tr>
                    </thead>
                    <tbody id="dataTablebodyedit">
                        <tr hidden>
                            <td>
                              <input type="text" class="form-control" id="attachment1" required />
                            </td>
                            <td>
                                <input type="file" class="form-control" id="attachmentfile_edit1"  onchange="OnValueChanges(this)" name="attachmentfile_edit" required />
                            </td>
                            <td>
                                <button type="button" class="btn login-align" name="name" onclick="deleteRow()" >Remove</button>
                            </td>
                        </tr>
                    </tbody>                                                            
                </table>

            </div>
        </div>
    </div>

    </br>
</div>

<div class="row">
    <div class="col-xs-12 col-sm-10">
        <div class="form-group">                                                    
            <a id="submitButton_edit" href="#" class="progress-button submit-align" onClick= "updatecomplaintbtn()">Submit</a>
            <a id="close_button"  class="progress-button" data-dismiss="modal"  onclick="reload()">Close</a>  
        </div>
    </div>
</div>

我的剧本,

<script>
    function reload() {
            //location.reload();

            $(document.body).on('hidden.bs.modal', function () {
                $('#myModal').removeData('bs.modal')
            });
        }
</script>

但在关闭模型并再次打开其显示的旧数据包括.. 我做错了什么。朋友们帮帮我......

Editapealrecords():

function editappealrecords(record) {
    var theUrl = '@Href("~/ChooseAction/GetGrievance")';
    var ID = $(event.target).closest('tr')[0].cells[0].innerHTML;
    $('#last-appeal').val(ID);
    $.ajax({
        type: "GET",
        url: theUrl,
        data: {
            ID: ID
        },
        dataType: "json",
        success: function (result) {

                    $('#myModal').modal('show');

                    var theUrlAttch = '@Href("~/ChooseAction/GetAttachment")';
                    var AttachID = ID
                    $.ajax({
                        type: "GET",
                        url: theUrlAttch,
                        data: {
                            ID: AttachID
                        },
                        dataType: "json",
                        success: function (result) {

                            var DtlAttach = Object.keys(result).length;

                            for (var i = 0; i < DtlAttach; i++) {
                                var test = '<tr><td><input type="text" class="form-control" id="attachment1" value="' + result[i].FileName + '" required /></td>' +
                                           '<td><input type="file"  class="form-control" id="attachmentfile_edit1" name="attachmentfile_edit1" value="' + result[i].FileName + '" onchange="OnValueChanges(this)"  /></td>' +
                                           '<td><input type="button" class="btn login-align" name="removebutton" value="Remove" /></td></tr>';
                                $('#dataTablebodyedit').append(test);
                            }
                    });

            }
            else {
                $('#modalsuccess-header')[0].innerHTML = 'Confirmation';
                $('#modalsuccess-body')[0].innerHTML = 'You cannot edit the Approved or Closed Appeal. Thank you';
                $('#myMsgModal').modal('show');
            }

        },
        failure: function () {

            $('#myModalError').modal('show');
        }
    });
};

0 个答案:

没有答案