skip to Main Content

I am new to Twitter Bootstrap. I am working on a modal panel. When I click on button to display modal it displays but then it freezes. If I click on close button or aside of modal nothing happens, modal is still there but “frozen”. Form fields are frozen also and I can’t use them.

This is my code:

<div class="content">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-md-12">

                            <!-- Button trigger modal -->
                            <button type="button" class="btn btn-primary" data-toggle="modal"
                                data-target="#myModal">Launch demo modal</button>

                            <!-- Modal -->
                            <div class="modal fade" id="myModal">
                                <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                        <form>
                                        <div class="modal-header">
                                            <h5 class="modal-title">Modal title</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 label-floating">
                                                    <label class="control-label">Username</label>
                                                    <input type="text" class="form-control" />
                                                </div>

                                                <div class="form-group label-floating">
                                                    <label class="control-label">Email address</label>
                                                    <input type="email" class="form-control" />
                                                </div>

                                                <div class="form-group label-floating">
                                                    <label class="control-label">Fist Name</label>
                                                    <input type="text" class="form-control" />
                                                </div>


                                                <div class="form-group label-floating">
                                                    <label class="control-label">Last Name</label>
                                                    <input type="text" class="form-control" />
                                                </div>

                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-primary">Save
                                                changes</button>
                                            <button type="button" class="btn btn-secondary"
                                                data-dismiss="modal">Close</button>
                                            </div>
                                        </div>
                                        </form>

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

2

Answers


  1. Here you go with the solution https://jsfiddle.net/nLu3s675/

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    
    
    <div class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-12">
    
            <!-- Button trigger modal -->
            <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Launch demo modal</button>
    
            <!-- Modal -->
            <div class="modal fade" id="myModal">
              <div class="modal-dialog" role="document">
                <div class="modal-content">
                  <form>
                    <div class="modal-header">
                      <h5 class="modal-title">Modal title</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 label-floating">
                        <label class="control-label">Username</label>
                        <input type="text" class="form-control" />
                      </div>
    
                      <div class="form-group label-floating">
                        <label class="control-label">Email address</label>
                        <input type="email" class="form-control" />
                      </div>
    
                      <div class="form-group label-floating">
                        <label class="control-label">Fist Name</label>
                        <input type="text" class="form-control" />
                      </div>
    
                      <div class="form-group label-floating">
                        <label class="control-label">Last Name</label>
                        <input type="text" class="form-control" />
                      </div>
    
                      <div class="modal-footer">
                        <button type="button" class="btn btn-primary">Save Changes</button>
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                      </div>
                    </div>
                  </form>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    Login or Signup to reply.
  2. I found solution that have worked for me. I have placed my modal under another bootstrap class, if you check code above

    <div class="content">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-md-12">...
    

    That’s why my modal was frozen on any action. When I have removed it under those classes and just placed it under <body> tag it worked.
    It seems it was css style conflict.

    So it looks like:

    <body>
    <div class="modal fade" id="myModal">
              <div class="modal-dialog" role="document">
                <div class="modal-content">
                  <form>
                    <div class="modal-header">
                      <h5 class="modal-title">Modal title</h5>
                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                      </button>
                    </div>... 
    

    Hope it helps someone with same issue.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search