我正在尝试在某个视图的页面加载时出现一个twitter-bootstrap模式对话框。我这样做是使用代码:
<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>
在页面加载时,屏幕显示“灰色”(褪色)而不显示模式,而不显示任何内容。任何人都知道会发生什么事吗?谢谢。
答案 0 :(得分:1)
嗯, 我认为你应该尝试使用Bootstrap 3:
<div class = "modal fade" id="shareModal" role = "dialog">
<div class = "modal-dialog">
<div class = "modal-content">
<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>
</div>
</div>
在浏览器的控制台中输入:$('#shareModal')。modal();测试你的模态
答案 1 :(得分:1)
<!-- 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">×</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 强>