2015-08-27 51 views
1

我在我的網站上使用Fullcalendar作爲我的callendar。這一切都很好,使用起來非常簡單。但是我偶然發現了一個「問題」,如下圖所示,有兩個按鈕(紅色箭頭)用於向前或向後跳躍一週。全加載跳月而不是一週

enter image description here

現在我的問題,是有可能與fullcalendar添加2個按鈕,將在一個月,而不是一週跳(所以有4個按鈕總共2周,2幾個月)?

我試圖添加2個按鈕,並onClick使日曆跳轉到curDate +一個月,但這並沒有很好的工作。

回答

1

使用fullcalendar v2.4很容易。你所要做的就是在構建日曆時使用customButtons和header選項。例如,以添加請求(prev和next月)的按鈕,你可以使用此代碼:

$("#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>

更多信息可以在官方文檔中找到:http://fullcalendar.io/docs/display/customButtons/

+0

謝謝!這正是我需要的。 –

相關問題