简体   繁体   English

模态不显示仅背景出现

[英]Modal is not showing up only the backdrop appears

This is my HTML code for the edit button. 这是我用于编辑按钮的HTML代码。 When I click the edit button there's no modal poping up. 当我单击编辑按钮时,没有模式弹出窗口。

 <div class="modal fade" id="editModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Edit record</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <input type="hidden" id="editid" name="id" class="form-control">
                    <input type="text" id="editname" name="name" class="form-control">
                </div>
            </div>
            <div class="modal-footer">
                <button type="submit" onclick="editModal(event)" class="btn btn-primary">Save changes</button>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

Here's the code for the second modal when you click the save changes. 这是单击保存更改时第二个模式的代码。

 <div class="modal fade" id="confirmationModal1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <form action="php/edit_client.php" method="post">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">Confirmation</h4>
                </div>
                <div class="modal-body">
                    Are you sure you want to edit this client?
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                    <button type="submit" class="btn btn-primary" onclick="validateForm()">Save</button>
                </div>
            </div> 
        </form> 
    </div>
</div> 

This is the javascript for the modal to show up. 这是模态显示的javascript。

 function validateForm(e) {

  }

  function editModal(event) {
    $("#editModal").modal("show");

    focusedid = e;
    identifier = focusedid.split('-')[1];

    $("#editid").val( $("#id-" + identifier).val() );
    $("#editname").val( $("#name-" + identifier).val() );
}

well seeing your code, maybe it is your browser version or is running a jquery before another, I had a similar problem, another project worked the following: 很好地看到了您的代码,也许是您的浏览器版本,还是先运行了一个jquery,我遇到了类似的问题,另一个项目的工作原理如下:

$('#editModal').on('show.bs.modal', function (event) { //here goes the modal id
  var button = $(event.relatedTarget) // Button that activated the modal
}  var modal = $(this)
  $('.alert').hide();
})

but in a different version, or so I think, modify my code to the following one: 但以其他版本(或我认为是这样),请将我的代码修改为以下代码:

$("#btn_show_modal").click(function(){ //here goes the button id that activates it
    $("#editModal").modal("show"); //here goes the modal id
});

but before, the button put the following code: 但在此之前,该按钮放置了以下代码:

<a data-toggle="modal" data-target="#editModal"> //where is the link to modal, and data-targat indicates to which modal id references. practicamente, la etiquieta a indica el vinculo a el modal, incluso puedes colocar ese viculo a el boton para ahorrar codigo.
    <button type="button" value="Modal"/> //default button
</a>

Preferably if you speak Spanish translate until the comments to understand it. 最好是,如果您说西班牙语,请先翻译成注释,然后再进行理解。 Good luck. 祝好运。

//De preferencia si hablas español traduce hasta los comentarios para entenderlo. Buena suerte.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM