我在html页面上有两个bootstrap模态,只打开第一个模态

时间:2014-04-16 03:34:08

标签: javascript twitter-bootstrap modal-dialog

我在html页面上有两个bootstrap模式,只打开第一个模态 第一个对话框打开,而第二个对话框不打开。

示例代码:http://www.bootply.com/130370#

HTML:

<button class="btn btn-primary" id="report" alt="report">Report Query Parameters</button>
<button class="btn btn-primary" id="reportData" alt="report">Report</button>
<div class="modal fade" id="modal-reportData" tabindex="-1" role="dialog" aria-labelledby="modal-title" aria-hidden="true">                                                 
          <div class="modal-dialog">
                <div class="modal-content report-modal-content">
                      <div class="modal-header">
                            <h4 class="modal-title" id="modal-title-report">Generated Report   </h4>
                      </div>
                      <div class="modal-body ">
                      <div class="modal-footer">
                      </div></div></div></div>

<div class="modal fade" id="modal-reportParameters" tabindex="-1" role="dialog" aria-labelledby="modal-title" aria-hidden="true">                                           
         <div class="modal-dialog">
                <div class="modal-content report-modal-content">
                      <div class="modal-header">
                            <h4 class="modal-title" id="modal-title-report">Report Query Parameters</h4>
                      </div>
                      <div class="modal-body node-inventory-modal-body">
                      <div class="row margin-bottom">
                      <form class="form-horizontal" role="form">
                    <div class="form-group">
                    <label for="colName" class="col-md-2 control-label"></label>
                    <div class="col-md-10">
                    </div>
                    </div>
                    </form>
                      </div>
                      <div class="modal-footer">
                        <button class="btn btn-primary" id="queryparameters">OK</button>
                        <button class="btn btn-default" data-dismiss="modal" id="cancel">Cancel</button>
                      </div></div></div></div>

JS

$('#report').click(function() {
$("#modal-reportParameters").modal('show');  
});   
$('#reportData').click(function() {
$("#modal-reportData").modal('show');

1 个答案:

答案 0 :(得分:0)

在您的HTML代码段中,您似乎错过了每个模态的结束div标记 - http://jsfiddle.net/5WvN7/

<button class="btn btn-primary" id="report" alt="report">Report Query Parameters</button>
<button class="btn btn-primary" id="reportData" alt="report">Report</button>
<div class="modal fade" id="modal-reportData" tabindex="-1" role="dialog" aria-labelledby="modal-title" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content report-modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="modal-title-report">Generated Report </h4>
      </div>
      <div class="modal-body ">
        <div class="modal-footer"> </div>
      </div>
    </div>
  </div>
</div>
<div class="modal fade" id="modal-reportParameters" tabindex="-1" role="dialog" aria-labelledby="modal-title" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content report-modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="modal-title-report">Report Query Parameters</h4>
      </div>
      <div class="modal-body node-inventory-modal-body">
        <div class="row margin-bottom">
          <form class="form-horizontal" role="form">
            <div class="form-group">
              <label for="colName" class="col-md-2 control-label"></label>
              <div class="col-md-10"> </div>
            </div>
          </form>
        </div>
        <div class="modal-footer">
          <button class="btn btn-primary" id="queryparameters">OK</button>
          <button class="btn btn-default" data-dismiss="modal" id="cancel">Cancel</button>
        </div>
      </div>
    </div>
  </div>
</div>