我有几个完整的日历,可用于各种用途,最近我发现我的dayClick事件没有在某些时段触发。日历每天有2个时隙,基本上是早上和晚上,唯一不起作用的是星期六晚上,以及日期范围的晚上时隙的最后一天。 dayClick在其他每个时隙都可以正常工作。我已经搜寻了,找不到任何有帮助的东西。我也尝试删除任何日期范围,但没有解决任何问题。实际上,它在任何星期六晚上都不会开火,我不知道为什么。让我知道您是否需要更多信息。谢谢
DateTime startDate = DateTime.Now.AddDays(-(int)DateTime.Now.DayOfWeek);
DateTime endDate =startDate.AddDays(7);
model.ShortStartDate = startDate.ToShortDateString();
model.ShortEndDate = endDate.ToShortDateString();
@{
var shortStartDate = Model.ShortStartDate.ToString();
var shortEndDate = Model.ShortEndDate.ToString();
var startDate = shortStartDate;
var endDate = shortEndDate;
}
<script>
var startDate = @startDate;
var endDate = @endDate;
var shortStartDate = @shortStartDate;
var shortEndDate = @shortEndDate;
var startoffSet = (new Date()).getTimezoneOffset() * 60000;
var endoffSet = (new Date()).getTimezoneOffset() * 60000;
$(document).ready(function () {
var calendarStartDate = new Date(startDate - startoffSet);
calendarStartDate.setDate(calendarStartDate.getDate() + 2);
var calendarEndDate = new Date(endDate - endoffSet);
calendarEndDate.setDate(calendarEndDate.getDate() + 2);
$('#scheduleEditCalendar').fullCalendar({
defaultView: 'agendaWeek',
views: {
agendaWeek: {
start: calendarStartDate.toISOString().slice(0, -1), //new Date(startDate - startoffSet).toISOString().slice(0, -1),
end: calendarEndDate.toISOString().slice(0, -1) //new Date(endDate - endoffSet).toISOString().slice(0, -1)
}
},
validRange: {
start: "@shortStartDate",
end: "@shortEndDate",
},
axisFormat: 'H(:mm)',
allDaySlot: false,
allDayDefault: false,
displayEventTime: false,
eventBackgroundColor: "#98700D",
visibleRange: {
start: calendarStartDate.toISOString().slice(0, -1),
end: calendarEndDate.toISOString().slice(0, -1)
},
dayClick: function (date, jsEvent, view) {
console.log("day clicked", date);
$("#dateChosenHidden").val(date.format().toString());
$.ajax({
url: '@Url.Action("AddUserToWalkPartial")',
type: 'GET',
data: $('#AddWalkerToScheduleForm').serialize(),
modal: true,
success: function (partialView) {
console.log("Date Chosen: " + $("#dateChosenHidden").val());
$('#AddWalkerModalContent').html(partialView);
$('#AddWalkerModal').modal({ backdrop: true, toggle: true });
}
});
},
eventClick: function (date, jsEvent, view) {
var today = moment(new Date());
console.log(view);
console.log(date.title);
if (today > checkDateStart && today < checkDateEnd){
$.ajax({
url: '@Url.Action("EditUserForWalkPartial")',
type: 'GET',
data: {eventDate: date.start._i, usersName: date.title, patientId: @Model.Patient.Id},
modal: true,
success: function (partialView) {
$('#AddWalkerModalContent').html(partialView);
$('#AddWalkerModal').modal({ backdrop: true, toggle: true });
}
});
}
},
eventSources: [{ events: eventss }],
eventRender: function (event, element, view) {
var cellheight = $(element).height();
$(element).css('height', '15px');
if (event.type == 'true') {
$(element).css('background-color', 'green');
}
else {
$(element).css('background-color', 'red');
}
}
})
$('#scheduleEditCalendar').fullCalendar('option', 'contentHeight', 'auto');
$('#scheduleEditCalendar').fullCalendar('option', 'minTime', '07:00:00');
$('#scheduleEditCalendar').fullCalendar('option', 'maxTime', '24:00:00');
$('#scheduleEditCalendar').fullCalendar('option', 'slotDuration', '12:00:00');
});