本文介绍了Twitter-bootstrap模式未显示在页面加载(灰色屏幕)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在某个视图的页面加载时出现一个twitter-bootstrap模式对话框。我这样做是使用代码:

I am trying to have a twitter-bootstrap modal dialog box appear on page load for a certain view. I am doing this using the code:

<script>
$(window).load(function(){
        $('#shareModal').modal('show');
    });
</script>

<div class="modal hide fade" id="shareModal">
  <div class="modal-header">
    <a class="close" data-dismiss="modal">×</a>
    <h3>Modal header</h3>
  </div>
  <div class="modal-body">
    <p>One fine body…</p>
  </div>
  <div class="modal-footer">
    <a href="#" class="btn">Close</a>
    <a href="#" class="btn btn-primary">Save changes</a>
  </div>
</div>

在页面加载时,屏幕显示为灰色(褪色),而不是模式弹出没有出现。任何人都知道会发生什么事吗?谢谢。

On page load, instead of the modal popping up, the screen appears "greyed" out (faded) and nothing appears. Anyone have any idea what could be going on? Thank you.

推荐答案

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        One fine body…
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

JS

$(window).load(function(){
        $('#myModal').modal('show');
    });

DEMO

这篇关于Twitter-bootstrap模式未显示在页面加载(灰色屏幕)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 04:24