Twitter Bootstrap 下拉菜单,打开模式

Twitterbootstrap dropdown, open modal

尝试打开一个下拉按钮,然后在单击下拉列表中的项目时它应该打开一个模式 - 但不起作用,添加了以下代码:

<button type="button" class="btn btn-lg btn-warning dropdown-toggle" data-toggle="dropdown">By industries <span class="caret"></span>
                  </button> 
                  <ul class="dropdown-menu" role="menu">
                    <li><a href="#consumergoods">Consumer goods</a></li>

                    <div class="modal fade" id="consumergoods" data-target="#consumergoods">
                                          <div class="modal-dialog">
                                            <div class="modal-content">
                                              <div class="modal-header orange">
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                <h4 class="modal-title"><strong></strong>Consumer goods</h4>
                                              </div>

可能做错了什么,但如果有人能提供帮助,我会很高兴,谢谢!

您需要为 button<ul> 包装器 div .dropdown 才能使下拉菜单正常工作,对于模式,您需要提供属性 data-toggle="modal" 到 link

<div class="dropdown">
    <button type="button" class="btn btn-lg btn-warning dropdown-toggle" data-toggle="dropdown">By industries <span class="caret"></span>    
    </button>
    <ul class="dropdown-menu" role="menu">
        <li><a href="#consumergoods" data-toggle="modal">Consumer goods</a></li>
    </ul>
</div>
<div class="modal fade" id="consumergoods" data-target="#consumergoods">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header orange">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>    
                </button>
                 <h4 class="modal-title"><strong></strong>Consumer goods</h4>    
            </div>
        </div>
    </div>
</div>

Fiddle