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

标签 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的函数,但我不知道如何实现它。如有任何帮助,我们将不胜感激。

编辑:日历可供多用户使用。可以为不同的用户设置事件。

最佳答案

好吧,我明白了。所有这些函数都会被调用,但你必须自己实现它们。所以这段代码设置了事件的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);
},

关于javascript - 添加新事件时在 jQuery weekcalendar 中获取 userId,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14218958/

相关文章:

javascript - Javascript 只匹配一个 URL

javascript - 在 GAE Python 中使用 XMLHttpRequest() PUT

javascript - 使用 php 或 javascript 从单个图像中读取多个条形码

javascript - jQuery Datalink 不使用对象方法

javascript - 通过 Websockets 进行 WebRTC 视频聊天

javascript - 一键将文本输入转换为JSON并将结果复制到剪贴板

javascript - 如何使用onclick按钮更改div下的样式

jquery - 如何使用窗口位置设置 div 样式

javascript - toggleClass 在 ajax 中不起作用

javascript - Blueimp 文件上传验证不起作用