javascript – bootstrap:多个模态

前端之家收集整理的这篇文章主要介绍了javascript – bootstrap:多个模态前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的网站上使用了两个bootstrap模式:
<!---- modal 1 ---->
       <div id="send-pm" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="send-pm" aria-hidden="true">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">Send Foobar a PM</h3>
          </div>
          <div class="modal-body">
            <p>One fine body…</p>
          </div>
          <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
            <button class="btn btn-primary">Send</button>
        </div>

        <!---- modal 2 --->
        <div id="post-comment" class="modal hide fade" tabindex="-2" role="dialog" aria-labelledby="post-comment" aria-hidden="true">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">Post a Comment</h3>
          </div>
          <div class="modal-body">
            <p>One fine body…</p>
          </div>
          <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
            <button class="btn btn-primary">Post</button>
        </div>

它们由以下因素触发:

<a href="#send-pm" data-toggle="modal" class="btn btn-small"> Send PM </a>
<a href="#post-comment" data-toggle="modal" class="btn btn-small"> Post Comment </a>

但是,只有第一个出现.我的第二篇评论后没有出现.控制台上没有JS错误.

有什么建议?

解决方法

使它们都有效.只需将它们放在不同的容器中,而不是一个接一个地容器

Demo

<a href="#send-pm" data-toggle="modal" class="btn btn-small"> Send PM </a>
<a href="#post-comment" data-toggle="modal" class="btn btn-small"> Post Comment </a>
<div>
        <!---- modal 2 --->
        <div id="post-comment" class="modal hide fade" tabindex="-2" role="dialog" aria-labelledby="post-comment" aria-hidden="true">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">Post a Comment</h3>
          </div>
          <div class="modal-body">
            <p>One fine body…</p>
          </div>
          <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
            <button class="btn btn-primary">Post</button>
        </div>
    </div>
    <div>
<!---- modal 1 ---->
       <div id="send-pm" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="send-pm" aria-hidden="true">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">Send Foobar a PM</h3>
          </div>
          <div class="modal-body">
            <p>One fine body…</p>
          </div>
          <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
            <button class="btn btn-primary">Send</button>
        </div>
        </div>

猜你在找的JavaScript相关文章