使用bootstrap模式淡入fullcalendar

时间:2014-05-02 23:04:34

标签: javascript jquery twitter-bootstrap fullcalendar

我试图淡入一个带有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">&times;</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');
    });
});

http://jsfiddle.net/waspinator/HfSLs/3/

1 个答案:

答案 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');

        }
    });
});

http://jsfiddle.net/waspinator/HfSLs/5/