Teddu
Teddu

Reputation: 209

Bootstrap modal doesn't appear like popup

I have created a datatable using jquery. Its second column has account numbers. When user will click on account number, then a modal should appear on the page. Something like below image.

enter image description here

But my modal doesn't appear like popup. It appears like this: enter image description here

Below is my code:

<div id="select-account-expanded" style="display:none">

        <!-- Begin of select-statement modal -->
        <div class="modal fade" id="select-statement-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display:none;">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="select-statement-title">Select Statement(s)</h4>
              </div>
              <div class="modal-body">
                  <table id="statement-table-modal">
                          <thead>
                                <tr>
                                    <th>
                                    <input type="checkbox" id="select-all-statement" value="" /><label for="select-all-statement"></label>
                                    </th>
                                    <th>Statement</th>
                                    <th>Due Date</th>
                                    <th>Total Due</th>
                                    <th>Payment Amount</th>
                                </tr>
                                </thead>
                       </table>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-primary">Continue</button>
              </div>
            </div>
          </div>
        </div> <!-- End of modal -->
              <table id="multiple-account-table">
                  <thead>
                        <tr class="border-class">
                            <th class="black white-active-bg pad-bottom-0-5">
                            <input type="checkbox" id="select-all-statement" value="" /><label for="select-all-statement"></label>
                            </th>
                            <th>Account Number</th>
                            <th>Account Name</th>
                            <th>Alias</th>
                            <th>Due Date</th>
                            <th>Total Due</th>
                            <th>Payment Amount</th>
                        </tr>
                        </thead>
                        <tbody>
                             <tr>
                                 <td>input type="checkbox" id="statement" value="" /><label for="select-all-statement"></label></td>
                                 <td><span id="launch-modal">1000</span></td>
                                 <td>Alwar</td>
                                 <td>07/07/2015</td>
                                 <td>$1000.00</td>
                                 <td><input type="textbox" value=""/></td>
                              </tr>

                         </tbody>
               </table>
    </div>

There is a link, by clicking on that link, modal appears. Below is javascript code for the same:

$(document).on('click', '#launch-modal', function () {
    $("#select-statement-modal").modal();
});

Any suggestion?

UPDATE I found my mistake. There was some mistake in importing bootstrap.min.css file. Now I have corrected.And it started working fine.

Upvotes: 1

Views: 1840

Answers (2)

Clario
Clario

Reputation: 342

Having spent a few hours debugging this same problem, I'd like to add a more detailed answer. The problem for me was that I mistakenly loaded the optional bootstrap theme css instead of the core css (on Wordpress):

wp_enqueue_style( 'bootstrap_css', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css',array(),'3.3.7' );

I should have loaded this:

wp_enqueue_style( 'bootstrap_css', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',array(),'3.3.7' );

(see the difference in the URL between the two).

Upvotes: 0

sumeet
sumeet

Reputation: 305

It Will work properly try to implement.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example of Bootstrap 3 Modals</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#myModal").modal('show');
	});
</script>
</head>
<body>
<div id="myModal" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <!-- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> -->
               
				 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="select-statement-title">Select Statement(s)</h4>
            </div>
            <div class="modal-body">
              <table class="table table-bordered">
			   <thead>
    <tr>
        <th data-field="id">Item ID</th>
        <th data-field="name">Item Name</th>
        <th data-field="price">Item Price</th>
    </tr>
    </thead>
	<tbody>
    <tr>
        <td><input type="checkbox" onclick="getRow(this)"  /></td>
        <td>aaa</td>
        <td>bbb</td>
    </tr>
    <tr>
        <td><input type="checkbox" onclick="getRow(this)" /></td>
        <td>ccc</td>
        <td>ddd</td>
    </tr>
    <tr>
        <td><input type="checkbox" onclick="getRow(this)" /></td>
        <td>eee</td>
        <td>fff</td>
    </tr>
	<tbody>
</table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">Continue</button>
               
            </div>
        </div>
    </div>
</div>
</body>
</html>                                		

Upvotes: 1

Related Questions