我正在使用 jquery 周历来安排一些约会,一切都很好,但我希望日历从上午 6:00 而不是上午 12:00 开始。我已经检查了所有 jquery 的公共功能以进行日历自定义,但找不到改变它的方法。我也检查了 jquery.weekcalendar.js 文件,但找不到实现此目的的方法(或无法理解该做什么)。有什么方法可以实现这一点,或者这个日历不可能?任何帮助将不胜感激。谢谢。
问问题
590 次
1 回答
0
您需要businessHours选项,start指定要显示的开始时间,end指定要显示的结束时间。
$('#calendar').weekCalendar({
data: eventData,
firstDayOfWeek: dayOfWeek,
timeslotsPerHour: 4,
allowCalEventOverlap: true,
overlapEventsSeparate: true,
totalEventsWidthPercentInOneColumn: 95,
buttons: false,
title: '',
// ***HERE IS THE OPTION YOU NEED TO USE***
businessHours: { start: 10, end: 22, limitDisplay: true },
height: function ($calendar) {
return $(window).height() - $('h1').outerHeight(true);
},
eventRender: function (calEvent, $event) {
if (calEvent.title == "Booked Slot") {
var classe = $event.attr('class');
$event.attr('class', classe + ' colr');
}
},
resizable: function (calEvent, $event) {
if (calEvent.title == "Booked Slot") {
return false;
}
return true;
},
draggable: function (calEvent, $event) {
if (calEvent.title == "Booked Slot") {
return false;
}
return true;
},
eventNew: function (calEvent, $event) {
debugger;
displayMessage('<strong>Added event</strong><br/>Start: ' + calEvent.start + '<br/>End: ' + calEvent.end);
//alert('You\'ve added a new event. You would capture this event, add the logic for creating a new event with your own fields, data and whatever backend persistence you require.');
var $dialogContent = $("#event_edit_container");
resetForm($dialogContent);
var startField = $dialogContent.find("select[name='start']").val(calEvent.start);
var endField = $dialogContent.find("select[name='end']").val(calEvent.end);
var titleField = $dialogContent.find("input[name='title']");
var bodyField = $dialogContent.find("textarea[name='body']");
$dialogContent.dialog({
modal: true,
title: "New Calendar Event",
close: function () {
$dialogContent.dialog("destroy");
$dialogContent.hide();
$('#calendar').weekCalendar("removeUnsavedEvents");
},
buttons: {
save: function () {
calEvent.id = id;
id++;
calEvent.start = new Date(startField.val());
calEvent.end = new Date(endField.val());
calEvent.title = titleField.val();
calEvent.body = bodyField.val();
$calendar.weekCalendar("removeUnsavedEvents");
$calendar.weekCalendar("updateEvent", calEvent);
$dialogContent.dialog("close");
},
cancel: function () {
$dialogContent.dialog("close");
}
}
}).show();
$dialogContent.find(".date_holder").text($calendar.weekCalendar("formatDate", calEvent.start));
setupStartAndEndTimeFields(startField, endField, calEvent, $calendar.weekCalendar("getTimeslotTimes", calEvent.start));
},
eventDrop: function (calEvent, $event) {
displayMessage('<strong>Moved Event</strong><br/>Start: ' + calEvent.start + '<br/>End: ' + calEvent.end);
},
eventResize: function (calEvent, $event) {
displayMessage('<strong>Resized Event</strong><br/>Start: ' + calEvent.start + '<br/>End: ' + calEvent.end);
},
eventClick: function (calEvent, $event) {
debugger;
displayMessage('<strong>Clicked Event</strong><br/>Start: ' + calEvent.start + '<br/>End: ' + calEvent.end);
if (calEvent.readOnly) {
return;
}
var $dialogContent = $("#event_edit_container");
resetForm($dialogContent);
var startField = $dialogContent.find("select[name='start']").val(calEvent.start);
var endField = $dialogContent.find("select[name='end']").val(calEvent.end);
var titleField = $dialogContent.find("input[name='title']").val(calEvent.title);
var bodyField = $dialogContent.find("textarea[name='body']");
bodyField.val(calEvent.body);
$dialogContent.dialog({
modal: true,
title: "Edit - " + calEvent.title,
close: function () {
$dialogContent.dialog("destroy");
$dialogContent.hide();
$('#calendar').weekCalendar("removeUnsavedEvents");
},
buttons: {
save: function () {
calEvent.start = new Date(startField.val());
calEvent.end = new Date(endField.val());
calEvent.title = titleField.val();
calEvent.body = bodyField.val();
$calendar.weekCalendar("updateEvent", calEvent);
$dialogContent.dialog("close");
},
"delete": function () {
$calendar.weekCalendar("removeEvent", calEvent.id);
$dialogContent.dialog("close");
},
cancel: function () {
$dialogContent.dialog("close");
}
}
}).show();
var startField = $dialogContent.find("select[name='start']").val(calEvent.start);
var endField = $dialogContent.find("select[name='end']").val(calEvent.end);
$dialogContent.find(".date_holder").text($calendar.weekCalendar("formatDate", calEvent.start));
setupStartAndEndTimeFields(startField, endField, calEvent, $calendar.weekCalendar("getTimeslotTimes", calEvent.start));
$(window).resize().resize(); //fixes a bug in modal overlay size ??
},
eventMouseover: function (calEvent, $event) {
displayMessage('<strong>Mouseover Event</strong><br/>Start: ' + calEvent.start + '<br/>End: ' + calEvent.end);
},
eventMouseout: function (calEvent, $event) {
displayMessage('<strong>Mouseout Event</strong><br/>Start: ' + calEvent.start + '<br/>End: ' + calEvent.end);
},
noEvents: function () {
displayMessage('There are no events for this week');
}
});
function displayMessage(message) {
//$('#message').html(message).fadeIn();
}
于 2017-04-06T05:38:41.590 回答