简体   繁体   English

Fullcalendar jQuery插件重复发生的事件日/周数(以月为单位)

[英]Fullcalendar jquery plugin recurring event day/week number in month

I'm trying to display the menu of a refectory by the plugin FullCalendar. 我正在尝试通过插件FullCalendar显示餐厅的菜单。 The menu should be something like that: 菜单应该是这样的:

  • 1st monday of month: pizza 一个月的第一个星期一:披萨
  • 2nd monday of month: pasta 一个月的第二个星期一:面食
  • 3rd monday of month: hamburger 一个月的第3个星期一:汉堡包
  • 4th monday of month: beef 一个月的第4个星期一:牛肉
  • 5th monday of month: soup 一个月的第5个星期一:汤
  • 1st tuesday of month: fish and chips 每月的第一周二:炸鱼和薯条
  • 2nd tuesday of month: potatos 每月的第二个星期二:土豆
  • 3rd tuesday of month: ... 每月的第3个星期二:...

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..)? 有没有一种方法可以设置正确的日期并根据需要在全日历中使用javascript date()函数,或者通过与其他技术混合使用(PHP / MySQL ..)?

Thanks in advance. 提前致谢。

I think there are two options: 我认为有两种选择:

  1. Create a Google Calendar, which supports this kind of recurring events, and add it to fullcalendar as shown here : 创建一个谷歌日历,支持这种经常性的活动,并把它添加到fullcalendar如图所示在这里

     <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> 
  2. Calculate the event on dates your own, as fullcalendar doesn't support recurring events. 由于全日历不支持重复发生的事件,因此请按您自己的日期计算事件。 You can use the datejs library as a little help: 您可以使用datejs库作为一点帮助:

     <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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM