I'm trying to display the menu of a refectory by the plugin FullCalendar. The menu should be something like that:
etc..
I need to recurring event in this way.. But I don't know if it's possible and how implement it.. I'm so confused.
At the moment my code will look something like that:
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
events: [
{ start: new Date(y, m, 1), title: 'Pasta all\'olio e parmigiano' },
{ start: new Date(y, m, 2), title: 'Pasta all\'olio e parmigiano' },
...
Is there a way to set the correct date and recurring in Fullcalendar as I need, using javascript date() function, or by mixing with another technologies (PHP/MySQL..)?
Thanks in advance.
I think there are two options:
Create a Google Calendar, which supports this kind of recurring events, and add it to fullcalendar as shown here :
<script type='text/javascript' src='fullcalendar/gcal.js'></script> <script type='text/javascript'> $(document).ready(function() { $('#calendar').fullCalendar({ events: 'http://www.google.com/your_feed_url/' }); }); </script>
Calculate the event on dates your own, as fullcalendar doesn't support recurring events. You can use the datejs library as a little help:
<script type='text/javascript' src='date.js'></script> <script type='text/javascript'> function getRecurrences(date, count) { var nthOccurence = Math.ceil((date.getDate() - date.getDay()) / 7), dates = [date]; for(var i = 0; i < count; i++) { var nextDate = dates[dates.length - 1].clone().addMonths(1); nextDate.moveToNthOccurrence(date.getDay(), nthOccurence); dates.push(nextDate); } return dates; } var date = new Date(2013, 8, 18); // 3rd Wednesday var nextThreeOccurences = getRecurrences(date, 3); </script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.