2014-01-24 63 views
1

我正在制作一个模式上的应用程序表单,我这样做是为了让用户可以将他们的照片上传到应用程序表单上。所以我的缩略图里面有一个“上传图片”的气泡,当我点击它时,会弹出一个模式。然而问题是当我点击我的“上传图片”模式上的“取消”或“上传”时,它会关闭两个模式窗口(申请表和上传图片)。有没有办法弹出另一个模态窗口?

我使用的引导,这里是我的代码片段:

<div class="modal fade in" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" style="display: block;"> 
<div class="modal-dialog"> 
    <div class="modal-content"> 
     <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 
      <h4 class="modal-title" id="myModalLabel">Application Form</h4> 
     </div> 

    <!-- START OF MODAL BODY--> 

     <div class="modal-body">   
      <div class="col-sm-5"> 
       <div class="thumbnail"> 
        <div class="avatar"> 
         <a href="#" class="thumbnail bottom-15" data-toggle="modal" data-target="#upload-avatar"> 
          <img src="img/face1.jpg" alt="..."> 
         </a> 
     <!-- Upload new avatar bubble --> 
         <div class="avatar-bubble"> 
          <a href="#" data-toggle="modal" data-target="#upload-avatar"><i class="fa fa-plus"></i> Upload new avatar</a> 
         </div> 
        </div> 
       </div> 
      </div> 
      <!--Modal for uploading photo--> 
      <div class="modal fade" id="upload-avatar" tabindex="-1" role="dialog" aria-labelledby="upload-avatar-title" aria-hidden="true" style="display: none;"> 
       <div class="modal-dialog"> 
        <div class="modal-content"> 
         <div class="modal-header"> 
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 
          <h4 class="modal-title" id="upload-avatar-title">Upload new avatar</h4> 
         </div> 
         <div class="modal-body"> 
          <p>Please choose a file to upload. JPG, PNG, GIF only.</p> 
           <form role="form"> 
            <div class="form-group"> 
             <label for="file">File input</label> 
             <input type="file" id="file"> 
             <p class="help-block">Files up to 5Mb only.</p> 
            </div> 
            <button type="button" class="hl-btn hl-btn-default" data-dismiss="modal">Cancel</button> 
            <button type="button" class="hl-btn hl-btn-green" data-dismiss="modal">Upload</button> 
           </form> 
         </div> 
        </div><!-- /.modal-content --> 
       </div><!-- /.modal-dialog --> 
      </div> 
     </div> <!-- END OF APPLICATION FORM MODAL BODY --> 

     <div class="modal-footer"> 
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
     </div> 
    </div><!-- /.modal-content --> 
</div><!-- /.modal-dialog --> 

基本上,我把我的第二模式我的第一模内。

+0

根据BS 3文档:“重叠模式不支持。确保注意打开模式,而另一个可见..”http://getbootstrap.com/javascript/#modals – ZimSystem

回答

0

虽然Bootstrap 3文档说“重叠模式不支持..”,我想我找到了一个解决方法。你需要..

  1. 确保您的第二个模式的标记是第一模态
  2. 身体的外侧使用jQuery中的引导模式toggle方法手动关闭第二模式。
  3. 更改第二个模态的z-index,使其显示在第一个模态上。

http://bootply.com/108243

另外,我改变了你的标记删除fade和`显示:无”。

0

我打开了另一种模态的模态。我称之为“模态”。这听起来像你只需要确保你的事件是针对正确的模式。

我有重叠的模态,他们按预期工作。点击第二个模式的背景只会关闭该模式,而不是其后面的模式。

0

只需正确设置z-index即可。一定不要嵌套它们,它应该工作得很好。它不是“支持”的,但我一直这样做。一个项目,我目前正在堆栈3上彼此没有问题。

我使用的是Bootstrap v3.3.2和jQuery 1.11.2。

相关问题