2014-04-04 30 views
0

我正在處理已使用fullcalendar呈現日曆的應用,只要頁面刷新時隙總是使用event render回調以正確的顏色呈現。它也正確更改事件被點擊時,使用event click回調時間槽的顏色。如何以編程方式更新fullcalendar中事件的呈現方式

這是非常好的,但是我試圖以編程方式基於用戶做的其他東西日曆完全加載後操作時間的渲染。在代碼中,這是我想要做的

var eventClick = function(calEvent, jsEvent, view) { 
    // first we change the color of the event to indicate that it was clicked 
    calEvent.backgroundColor = orangeColor; 
    calEvent.textColor= darkGreyColor; 
    calEvent.active=true; 
    $(this).css('background', orangeColor).css('color', darkGreyColor); 

    // i cache both the calEvent and the element to manipulate them later on 
    cachedActiveEvents.push(calEvent); 
    // here i'm storing this div: <div class="fc-event fc-event-vert ..> 
    //        <div class="fc-event-inner"> 
    //         <div class="fc-event-time">12:30 - 1:20</div> 
    //         <div class="fc-event-title">event title</div> 
    //         .. 
    cachedActiveEventViews.push($($(jsEvent.target).parent().parent())); 

    .. 

點擊後,該程序顯示一個模式窗體,用戶填寫。在該對話框的完成和解僱,點擊事件需要改變其顏色,以反映狀態的變化,這就是我把這個方法:

function hideLessonPlan() { 
    .. 
    $.map(cachedActiveEvents, function(calEvent, eventIndex) { 
     var element = cachedActiveEventViews[eventIndex]; 
     calEvent.backgroundColor = blackColor; 
     calEvent.textColor = "white" 
     element.css('background', blackColor).css('color','white'); 
    }); 
} 

這根本不起作用。使用Chrome開發工具斷點,我確保函數hideLessonPlan實際與正確的變量進行對話。

經進一步調查,我意識到,在這兩種event renderevent click回調..功能updateEvent(event)爲背景屬性被設置後調用。不過我的情況..此事件設置之後調用屬性。所以我的問題是更多的:我怎麼能從外面調用這個upateEvent方法?它看起來像一個私人變量。

更新:我做了它的工作,但只是通過存儲所選div的css屬性,然後使用jquery找到相同的div並手動高亮顯示它的後綴。對這種冒險的方式不太高興......希望有人會過來告訴我如何通過fullcalendar來做到這一點。

回答

1

事實證明,我根本就更新calendarEvent的財產即

calEvent.isActive = true; 
calEvent.status = 0; // ie in progress 

然後調用update event

$('#calendar').fullCalendar('updateEvent',calEvent); 

是照顧所有的渲染對我來說

相關問題