我试图淡入一个带有fullcalendar的bootstrap模式,而不会弹出fullcalendar。如何在开始模式淡入之前渲染日历?
HTML
<!-- Button trigger modal -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">Launch demo modal</button>
<!-- 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">
<div id='calendar'></div>
</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>
</div>
</div>
JS
$(document).ready(function () {
$('#calendar').fullCalendar({
})
$('#myModal').on('shown.bs.modal', function (e) {
$('#calendar').fullCalendar('render');
});
});
答案 0 :(得分:0)
从模态中删除fade
类,并将JS更改为以下内容:
$(document).ready(function () {
$('#calendar').fullCalendar({
})
var shown = false;
$('#myModal').on('shown.bs.modal', function (e) {
if(shown === false) {
shown = true;
$('#calendar').fullCalendar('render');
$('#myModal').modal('hide');
$('#myModal').addClass('fade');
$('#myModal').modal('show');
}
});
});