简体   繁体   English

全日历跳月而不是周

[英]Fullcalendar jump month instead of week

I'm using Fullcalendar as my calendar on my website. 我正在使用Fullcalendar作为我网站上的日历。 It all works great and it's really easy in use. 一切都很好,而且非常易于使用。 But I stumbled upon one "problem", as you can see in the picture below, there are two buttons(red arrows) these are for jumping a week forward or backwards. 但是我偶然发现了一个“问题”,如下图所示,有两个按钮(红色箭头)用于向前或向后跳跃一周。

在此处输入图片说明

Now my question, is it possible with fullcalendar to add 2 buttons that will jump one month instead of a week(so there are 4 buttons in total, 2 for weeks, 2 for months)? 现在我的问题是,是否可以使用fullcalendar添加2个按钮,这些按钮将跳一个月而不是一周(所以总共有4个按钮,其中2个代表星期,2个代表几个月)?

I have tried to add 2 buttons and onClick make the calendar jump to curDate+one month, but that didn't work very good. 我尝试添加2个按钮,然后onClick使日历跳至curDate +一个月,但这并不十分有效。

It's very easy to do using fullcalendar v2.4. 使用fullcalendar v2.4非常容易。 All you have to do is use the customButtons and header options when constructing your calendar. 您要做的就是在构造日历时使用customButtons和标头选项。 For example to add the buttons you request (prev and next month), you can use this code: 例如,要添加您请求的按钮(上个月和下个月),可以使用以下代码:

  $("#calendar").fullCalendar({ customButtons: { prevMonth: { text: 'previous month', click: function() { $("#calendar").fullCalendar('incrementDate', '-P1M'); } }, nextMonth: { text: 'next month', click: function() { $("#calendar").fullCalendar('incrementDate', 'P1M'); } } }, header: { left: 'prevMonth,today,nextMonth', center: 'title', right: 'month,agendaWeek,agendaDay' } }); 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment-with-locales.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.4.0/fullcalendar.min.css" rel="stylesheet"/> <script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.4.0/fullcalendar.min.js"></script> <div id="calendar"></div> 

More information can be found in the official docs: http://fullcalendar.io/docs/display/customButtons/ 可以在官方文档中找到更多信息: http : //fullcalendar.io/docs/display/customButtons/

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

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