1

我正在使用jQuery weekcalendar在日历中显示 appoitments 并通过简单的点击添加新的。在eventNew 函数中,我尝试获取userId已添加约会的 。谁能告诉我如何实现这一目标?

我能够得到约会的开始和结束日期:

eventNew : function(calEvent, $event, FreeBusyManager, calendar) {
  var isFree = true;
  $.each(FreeBusyManager.getFreeBusys(calEvent.start, calEvent.end), function() {
    if (
      this.getStart().getTime() != calEvent.end.getTime()
      && this.getEnd().getTime() != calEvent.start.getTime()
      && !this.getOption('free')
    ){
      isFree = false;
      return false;
    }
  });

  // add the event to the database
  console.log('start of new calendar event: ' + calEvent.start);
  console.log('end of new calendar event: ' + calEvent.end);
  // how do I get the userId here?
}

Wiki中,我找到了一个名为 的函数getUserId,但我不知道如何实现它。任何帮助表示赞赏。

编辑:日历已准备好多用户。可以为不同的用户设置事件。

4

1 回答 1

0

好的,我想通了。所有这些函数都被调用,但你必须自己实现它们。所以这段代码设置userId了事件的:

setEventUserId: function(userId, calEvent, calendar) {
     console.log('set eventuserid is called');
     calEvent.userId = userId;
     return calEvent;
},

然后eventNew你可以调用userId

eventNew : function(calEvent, $event, FreeBusyManager, calendar) {
  var isFree = true;
  $.each(FreeBusyManager.getFreeBusys(calEvent.start, calEvent.end), function() {
    if (
      this.getStart().getTime() != calEvent.end.getTime()
      && this.getEnd().getTime() != calEvent.start.getTime()
      && !this.getOption('free')
    ){
      isFree = false;
      return false;
    }
  });

  // add the event to the database
  console.log('start of new calendar event: ' + calEvent.start);
  console.log('end of new calendar event: ' + calEvent.end);
  console.log('userId of new calendar event: ' + calEvent.userId);
},
于 2013-01-08T16:28:57.057 回答