2011-09-26 64 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

相关问题