I want to load a modal dialog using bootstrap modal. Inside of it i want to show a fullcalendar (the jquery one) with some events on it. I have created my modal, and put inside the full calendar. But Full calendar won't show when modal appears. But it shows when after the modal has appeared i press on either next or previous buttons. But then no event appears on the calendar.jsfiddle here and code
<a href="#myModal" role="button" class="btn btn-default" data-toggle="modal">Launch demo modal</a>
<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">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<div class="row">
<div class="col-xs-6">
<div id="calendar"></div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
js
$("#calendar").fullCalendar({
header:{
left:'prev',
center:'title',
right:'next'
},
events:'/eventsfeed/',
defaultView:'agendaDay'
});
That also make events not to appear on calendar. This is what my /eventsfeed is returning
[{"url": "/calendar/entry/223", "start": "2013-12-04T17:00:00Z", "end": "2013-10-04T16:45:00Z", "description": "a body", "title": "Title entry"}]
I use fullcalendar in different pages of my project and events and everything render normally.
How can i make it load when modal appears
You should try this :
$('#myModal').on('shown.bs.modal', function () {
$("#calendar").fullCalendar('render');
});
Here is your fiddle : http://jsfiddle.net/mzAEj/2/
Here is the documentation : http://arshaw.com/fullcalendar/docs/display/render/
In reading the doc you can read that this command is deprecated,
You've to call calendar.render() is order to have the same behaviour
Extract of code :
var calendarEl = document.getElementById('calendar');
var calendar = new Calendar(calendarEl, {
plugins: [ dayGridPlugin ]
});
calendar.render();
Doc source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With