验证失败时,如何保持Bootstrap模式保持原样?

时间:2015-01-02 19:07:21

标签: javascript c# jquery html twitter-bootstrap

我使用了bootstrap模式,我将在单击按钮时显示..该模式具有表单元素..当它全部填充并提交时,它将命中服务并带来响应状态。如果响应状态为成功,则模态可以隐藏,否则它应保持不变..

<div class="modal fade" id="mdlRefId">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="H1">Issue Book</h4>
                </div>
                <div class="modal-body">
                    <div class='form-group' id="Div6">
                        <label class='col-md-6 control-label' id='Label3'>Book Reference Number:</label>
                        <div class='col-md-4'>
                            <input id='refNo' type='text' name='refNo' class='form-control'>
                        </div>
                    </div>
                    <input type="hidden" id="__ID" />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="mvSelectedBook()">Move to Selected Book</button> // mvSelectedBook() function given below
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

    // On this function, the above modal will show
    $(document).on("click", ".modalClick", function (e) {
            if (document.getElementById("txtERPNo").value != "") {
                $('#mdlRefId').modal('show');
            }
            else {
                $('#mdlRefId').modal('hide');
                alertify.error("Please enter ERP number").dismissOthers();
            }
        });


      function mvSelectedBook() {
        // here ajax call performed and get response from the server side

        if (BookObj.Status != "SUCCESS") {

            if (document.getElementById("hdnBookRefIds").value == "")
                document.getElementById("hdnBookRefIds").value = BookObj.BookRefId;
            else
                document.getElementById("hdnBookRefIds").value += ',' + BookObj.BookRefId;

            populateSelectedBooks();
        }
        else {
            $('#mdlRefId').modal('show'); // This is not working now
        }
    }

单击按钮时,此脚本为$('#mdlRefId')。modal('show');工作并显示模态对话框..但在获得响应时,它不会像调用此脚本时那样保持...提前感谢

0 个答案:

没有答案