Bootstrap 4模式不加载仅显示褪色的屏幕

时间:2019-02-08 11:32:12

标签: javascript html5 bootstrap-4 modal-dialog bootstrap-modal

我试图在单击按钮时加载引导程序模式。

我已经在页面中添加了一个模态,它运行良好,但是在单击按钮时,但是当我尝试在单击按钮时加载另一个模态时,它只是在加载褪色的屏幕。

<button class="btn btn-green btn-sm" data-toggle="modal" data-target="#addUserModal"><i class="fa fa-plus"></i> <span>Add User</span></button>

<!-- Add User Modal -->
          <div class="modal fade" id="addUserModal" role="dialog" aria-labelledby="addUserModalLabel" aria-hidden="true">
            <div class="modal-dialog">
              <!-- Modal content-->
              <div class="modal-content">
                <div class="modal-header">
                  <h6 class="modal-title">Add User</h6>
                  <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body">
                  <form action="" method="POST">
                    <div class="input-group mb-3">
                      <div class="input-group-prepend">
                        <span class="input-group-text">User ID</span>
                      </div>
                      <input type="text" class="form-control" id="user_id" value="{{user.UserID}}">
                    </div>
                    <div class="input-group mb-3">
                  </form>
                </div>
                <div class="modal-footer">
                  <button type="submit" class="btn btn-primary">Submit</button>
                  <button type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button>
              </div>
            </div>    
          </div>

2 个答案:

答案 0 :(得分:1)

您的-tags是否有错误?这可能会导致模态主体出错。

<div class="modal-body">
              <form action="" method="POST">
                <div class="input-group mb-3">
                  <div class="input-group-prepend">
                    <span class="input-group-text">User ID</span>
                  </div>
                  <input type="text" class="form-control" id="user_id" value="{{user.UserID}}">
                </div>
                //removed orphan tag
              </form>
            </div>

删除后,模态可以正常工作。

答案 1 :(得分:0)

您发布的代码运行正常

Codepen Link

确保已添加jquerypopper.js