简体   繁体   English

使用锚标签打开Bootstrap Modal

[英]Opening Bootstrap Modal with anchor tag

I am trying to open a Bootstrap Modal using the anchor tag. 我正在尝试使用锚标记打开Bootstrap Modal。 This is my HTML: 这是我的HTML:

   <ul class="dropdown-menu">
      <li><a data-toggle="modal" href="#createModal">create group chat</a>
             <!-- Modal -->
                  <div class="modal fade" id="createModal" role="dialog">
                    <div class="modal-dialog">
                      <!-- Modal content-->
                      <div class="modal-content">
                        <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal">&times;</button>
                          <h4 class="modal-title">Modal Header</h4>
                        </div>
                        <div class="modal-body">
                          <p>Some text in the modal.</p>
                        </div>
                        <div class="modal-footer">
                          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        </div>
                      </div>

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

When I click on the anchor tag for create group chat , the background blacks out but the actual dialog box does not appear. 当我单击锚标记以create group chat ,背景会变黑,但实际的对话框不会出现。 My website has another Bootstrap Modal that load when the page first loads, so I am not sure if this problem is being caused by a naming conflict. 我的网站上有另一个Bootstrap Modal,它是在页面首次加载时加载的,因此我不确定此问题是否是由命名冲突引起的。 This Modal is named createModal and the other one I am using is called myModal 该模态名为createModal ,而我正在使用的另一个模数称为myModal

Try moving the modal outside of the li element. 尝试将模态移到li元素之外。

Also, to get the fiddle working, you just need to add the external references to bootstrap. 另外,要使小提琴正常工作,您只需向引导程序添加外部引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM