我正在使用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/