添加新事件时,在jQuery weekcalendar中获取userId

时间:2013-01-08 15:56:09

标签: javascript jquery jquery-plugins

我正在使用jQuery weekcalendar在日历中显示约会,并通过简单的点击添加新的约会。在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的函数,但我不知道如何实现它。任何帮助表示赞赏。

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

1 个答案:

答案 0 :(得分: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);
},