2016-09-22 65 views
-1

當前月份的當前按鈕禁用。當你下個月或上個月去時,它會顯示爲活動狀態(點擊TODAY按鈕控件會轉到當前月份)。Fullcalendar,使當前月份的按鈕生效

在以下代碼中,我展示瞭如何使當前按鈕在當前月份處於活動狀態。

function makeTodaybtnActive() 
     { 
     $('#calendar button.fc-today-button').removeAttr('disabled'); 
     $('#calendar button.fc-today-button').removeClass('fc-state-disabled'); 
     } 

(其中#calendar是fullcalendar ID)
調用此功能時,日曆負載

$(window).load(function() { 
    makeTodaybtnActive(); 
}); 

而且在eventRender功能

$('#calendar').fullCalendar({ 
     eventRender: function(event, element) { 
      makeTodaybtnActive(); 
     }, 
    }); 

當日歷負載(頁面加載)那個時候第一個代碼工作,當改變月份並且到當前月份(通過cli今天點擊按鈕),然後第二個代碼使今天按鈕激活。

+1

你的問題不清楚,你應該提到你期望的結果。 –

+0

當今天的日期在渲染的日曆區域中可見時,'今日'按鈕將自動變爲非活動狀態,因爲如果已經顯示,則跳轉到'今天'是沒有意義的。 – smcd

+0

@abhishek我不問問題,我正在告訴如何爲當前的活動Today按鈕。 – Dinesh

回答

0

今天按鈕禁用當前月份。當你下個月或上個月去時,它會顯示爲活動狀態(點擊TODAY按鈕控件會轉到當前月份)。

在以下代碼中,我展示瞭如何使當前按鈕在當前月份處於活動狀態。

function makeTodaybtnActive() 
     { 
     $('#calendar button.fc-today-button').removeAttr('disabled'); 
     $('#calendar button.fc-today-button').removeClass('fc-state-disabled'); 
     } 

(其中#calendar是fullcalendar ID)
調用此功能時,日曆負載

$(window).load(function() { 
    makeTodaybtnActive(); 
}); 

而且在eventRender功能

$('#calendar').fullCalendar({ 
     eventRender: function(event, element) { 
      makeTodaybtnActive(); 
     }, 
    }); 

當日歷負載(頁面加載)那個時候第一個代碼工作,當改變月份並且到當前月份(通過cli今天點擊按鈕),然後第二個代碼使今天按鈕激活。

0

FullCalendar中,當我們在今天的日期時,今天按鈕被自動禁用。請檢查下面的代碼。

$('#calendar').fullCalendar({ 
 
    events: [{ 
 
     title: 'Event 1', 
 
     start: moment().add(1, 'h'), 
 
     end: moment().add(2, 'h'), 
 
     allDay: false 
 
    }], 
 
    header: { 
 
     left: '', 
 
     center: 'prev title next today', 
 
     right: '' 
 
    }, 
 
    timezone:'local', 
 
    defaultDate: '2014-11-15', 
 
    editable: false, 
 
    eventLimit: false, 
 
    firstDay: 6, 
 
    defaultView: 'agendaWeek', 
 
}); 
 
      
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> 
 
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js"></script> 
 
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.css" rel="stylesheet" /> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.js"></script> 
 

 
<div id="calendar"></div>

+0

請讓我知道如果你想要別的東西..它解決了你的問題,然後請接受這個答案和UPVote。 –

0

的「今天」按鈕由自動不活動時,今天的日期是在渲染日曆區域中可見,因爲沒有點跳躍到「今天」,如果它已經可見。如果你真的希望它總是被啓用,也可以https://jsfiddle.net/73b7rva6/

document.addEventListener('DOMContentLoaded', function() { 
    $('#calendar').fullCalendar({ 
     eventAfterAllRender: function(view) { /* used this vs viewRender */ 
      makeTodayButtonActive(); 
     } 
    }); 

    function makeTodayButtonActive() { 
     /* turn off fc-state-disabled class and remove 'disabled' property */ 
     $('#calendar button.fc-today-button').removeClass('fc-state-disabled').prop('disabled', false); 
    } 
}); 
+0

我不問問題。我正在告訴如何去做。 – Dinesh