Pregunta

I'm trying to fade in a bootstrap modal that has a fullcalendar in it without having the fullcalendar pop in. how would I render the calendar before starting the modal fade in?

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/

¿Fue útil?

Solución

remove the fade class from the modal and change the JS to the following:

$(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/

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top