2011-09-26 149 views
0

我的問題是: 如果今天的日期是FullCalendar中事件的日期,是否可以觸發某些內容(即ale​​rt,Qtip,無論什麼)?我使用Google日曆中的XML作爲源代碼,希望能爲人們的生日提供一些信息。事件日期的FullCalendar提醒

我已經有了:

var difference = birthdate - today; 
var days = Math.round(difference/(1000*60*60*24)); 

if (days == 0){ 
    $('#tabs').qtip({ 
    position: { 
       my: 'bottom right', 
       at: 'top left', 
    }, 
    content: "It's someone's birthday!!!", 
    show: { 
     when: false, 
     ready: true 
    }, 
    hide: false, 
    style: { 
     classes: 'ui-tooltip-rounded', 
     } 
    }); 
} 

生日是個人的生日(這是我設置爲VAR)和今天是,很明顯,今天的日期。 我的問題是,這不是很有活力,因爲我將不得不爲每個人單獨做這件事。

非常感謝提前。

回答

3

當您創建日曆對象/函數時,您需要創建一個eventAfterRender函數。這隻有當你有一個已經放置在日曆上的功能時纔會觸發。然後你可以讀取日期並將其與生日和顯示彈出對比。我希望這就是你想要的。我舉了一個小例子。

$(document).ready(function() { 
      $('#calendar').fullCalendar({ 
       height: 600, 
       width: 700, 
       header: { 
        right: 'prev,next today', 
        center: 'title', 
        left: 'month,agendaWeek,agendaDay' 
       }, 
       eventAfterRender: function (event, element, view) { 
        birthday = new Date('<somedate>'); 
        year = new Date(event.start).getFullYear(); 
        month = new Date(event.start).getMonth(); 
        day = new Date(event.start).getDate(); 
        alert(year + ' ' + month + ' ' + day); 
    //do some if statement to see if the year matches then if the month, then the day. 
//if so then go to another function or just put the code here for the pop 

       } 
      }); 
     }); 
+0

aaah,好的,我明白了。非常感謝。 – DeagleDaemon

+0

如果這是答案,不要忘記標記它,所以其他人都知道。不用謝。祝你好運。 – blackops

相關問題