【发布时间】:2016-01-14 01:49:38
【问题描述】:
我正在尝试使用完整日历避免在同一天重复活动。 我有一个名为 'Blocked' 的事件,如果特定日期已经有一个 Blocked 事件,则不允许用户添加另一个事件。
我的问题是,如何在客户端获取特定日期的事件列表?
这是我的代码:
$(document).ready(function () {
$('.calendar').fullCalendar({
dayClick: function (date, jsEvent, view, resourceObj) {
// Here I would like to check if this date already have a 'Blocked' event, if yes do not need to render another event and make another ajax call.
var newEvent = {
title: 'Blocked',
start: date
};
$('.calendar').fullCalendar('renderEvent', newEvent, 'stick');
$.ajax({
type: "GET",
url: "block_date",
dataType: "json",
data: {date: date.toJSON()},
error: function (result) {
$('.calendar').fullCalendar('removeEvents', newEvent);
}
});
},
eventClick: function (calEvent, jsEvent, view) {
if (calEvent.title == 'Blocked') {
$('.calendar').fullCalendar('removeEvents', calEvent._id);
$.ajax({
type: "GET",
url: "unblock_date",
dataType: "json",
data: {date: calEvent.start.toJSON()},
error: function (result) {
$('.calendar').fullCalendar('renderEvent', calEvent);
}
});
}
}
}
);
});
【问题讨论】:
标签: jquery events duplicates fullcalendar