【发布时间】:2013-12-04 09:39:10
【问题描述】:
我有以下 javascript 代码
$("#modal-yes-button").click(function (){
$("#myModal").modal('hide');
$(".modal-body").load('/url/that/returns/an/html/');
$("#myModal").modal('show');
});
和下面的模态
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
</div>
<div class="modal-body">
<h3>This is a question answer yes or later</h3>
</div>
<div class="modal-footer">
<button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Maybe Later</button>
<button id="modal-yes-button" class="btn btn-info" aria-hidden="true">Yes</button>
</div>
</div><!--modal-content-->
</div><!--modal-dialog-->
</div><!--myModal-->
我希望用户按下“是”按钮隐藏模式(它表示当另一个模式打开时引导程序不允许模式打开)为 .modal-body 加载新的 html 内容并再次显示模式对话框。只有我得到的是黑屏(比如当模态出现阴影时),但模态永远不会出现。我使用 chrome 开发工具玩过它,模态显示正常
chrome 开发工具
modaldialog = $("#myModal");
modaldlgBody = $(".modal-body");
modaldlgBody.load('/url/that/returns/html/');
modaldialog.modal('show');
通过上述命令,新的新“body”被正常加载。但是,如果我尝试先加载对话框然后按下是按钮,即使从 chrome 开发工具触发模式,我也会得到相同的行为,黑屏。有什么问题?
提供相同黑屏的chrome开发工具
modaldialog = $("#myModal");
modaldialog.modal('show');
#pressing yes gets me the same black screen.
【问题讨论】:
-
正如用户建议的那样(谁删除了他的评论),我正在使用 $(".modal-body").load('/url/that/returns/ 加载 ajax 后显示页面html/', function(){ $("#myModal").modal('show'); });并且工作正常。但是现在当我按下可能稍后按钮时它具有相同的行为。关闭模式,但我没有返回到我的页面,但我只是得到黑色阴影页面,就像模式没有内容一样
标签: jquery twitter-bootstrap modal-dialog jquery-load