我正在尝试使用bootstrap 3.0模式使用jQuery Ajax加载器将外部html文件加载到模式中,但是它不会在第一次调用时显示,但适用于后续调用。
<a data-toggle="modal" data-target="#myModal" href="#myModal" id="myModal" aria-hidden="true">Department</a>
<div class="contianer">
<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">
<img src="img/logo.png" width="150" alt="SmartAdmin">
</h4>
</div>
<div class="modal-body no-padding">
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$('#myModal').click(function(e){
e.preventDefault();
$.ajax({
type: "GET",
url: "?AId=DEPT_ADDUPDATE",
data: { },
success: function(data){
$('.modal-body').html(data);
}
});
});
</script>
答案 0 :(得分:2)
只需添加:
success: function(data){
$('.modal-body').html(data);
$('#myModal').modal("show");
}