Reputation: 251
can someone please tell me why calendars don't show in the modal? But without modal they do show just fine. See this first where it works:Fiddle See this where it doesn't: Fiddle
I think I need to use fullCalendar('render');
but even with that, code didn't seem to work right inside the click function. Please assist.
Upvotes: 0
Views: 227
Reputation: 484
It appears fullCalendar won't render if any of its parents have display: none;
. The render
method you referenced is just the what you need to use, but you need to do so just after the model is displayed.
Alternately you could try something to leave the model with display: block;
, but positioned off screen (left: -1000%; right: 1000%;
or the like) until you want it visible.
Upvotes: 1
Reputation: 902
Here is what i did to make it work in your modal version. I created a function as you suspected that adds the calendar into the modal and called it when the "mark Vacation" button is clicked.
$('#vacaBtn').click(function () {
modal.style.display = "block";
renderCalendars();
});
I put all the code that creates the three calendars inside the renderCalendars() function so that they get added into the modal after the modal shows up.
function renderCalendars() {
$('#calendar0').fullCalendar({
header: {
left: '',
center: 'title',
right: ''
},
defaultDate: moment(y+"-"+(m+1)+"-"+d),
theme: true,
dayClick: function(date, jsEvent, view) {
alert('Clicked on: ' + date.format());
}
});
$('#calendar1').fullCalendar({
header: {
left: '',
center: 'title',
right: ''
},
defaultDate: moment(y+"-"+(m+2)+"-"+d),
theme: true
});
$('#calendar2').fullCalendar({
header: {
left: '',
center: 'title',
right: ''
},
theme: true,
defaultDate: moment(y+"-"+(m+3)+"-"+d)
});
}
Upvotes: 1