2011-12-24 35 views
2

我只顯示最初拿出20分鐘slotMinutes的日曆。我試圖讓用戶在飛行中更改爲10分鐘slotMinutes。更改插槽分鐘

我有一個按鈕,觸發下面的代碼:

$('#calendar').fullCalendar('option', 'slotMinutes', 10); 

,但我不能讓屏幕重繪反映新的設置。我曾嘗試過:

$('#calendar').fullCalendar("render") 
$('#calendar').fullCalendar("refetchEvents"); 

我正在使用agendaWeek視圖並希望它重繪並保持同一周。

我傾注了文檔。我錯過了什麼?

+0

你試過rerenderEvents? –

回答

0

因爲這將需要重新繪製整個日曆,爲什麼不從視圖中刪除舊的#calendar實例並使用新的slotMinutes選項重新加載完整日曆?您可以使用getView()函數獲取當前視圖的當前view.start/view.end和view.name(http://arshaw.com/fullcalendar/docs/views/View_Object/)。 http://arshaw.com/fullcalendar/docs/views/getView/

然後,在您重繪日曆調用「goToDate」並使用上面的「開始」日期/時間更改爲上次使用的日期之後。

它很髒,但它的工作原理。

0

您無法更改fullcalendar的選項。目前尚不支持。無論如何,唯一的方法就是重建整個對象。

一說起這個提升是here

github做了一個骯髒的叉我的需要,它可能適合你的。

我貼的差異在這裏(更新fullcalendar.js):

function option(name, value) { 
    if (value === undefined) { 
     return options[name]; 
    } 
    if(options[name] === value) 
     return; 
    options[name] = value; 
    if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') { 
     updateSize(); 
    } 
    else { 
     options.events = options.backupEvents; 
     $(element).fullCalendar('destroy'); 
     $(element).fullCalendar(options);    
    } 
} 
+0

那麼你會怎麼實現呢?用新選項調用fullcalendar似乎不起作用或觸發上述代碼。 – mozgras

+0

哦,我看到:$('#calendar')。fullCalendar('option','slotMinutes',10); – mozgras

+0

不幸的是,這消除了事件選項。 – mozgras