FullCalendar 月视图中一天的第一个小时
FullCalendar first hour of the day in month view
所以我遇到了以下问题:
正如您在屏幕截图中看到的,我添加了 2 个相差 1 分钟的事件。两个事件都在同一 Date/Time 开始,但一个在 08:59 AM 结束,另一个在 09:00 AM(同一天)结束,为什么月视图呈现这样?
我怀疑我应该在月视图中设置一个 first_our_of_day 参数,但我在文档中没有看到类似的内容。
编辑:
这是我的代码:
var calendar;
$(document).ready(function() {
calendar = $('#calendar').fullCalendar({
// eventLimit: true,
axisFormat: 'h:mm T',
header:{
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
eventClick: function(calEvent, jsEvent, view) {
event_id = calEvent.id;
show_ticket_details(event_id);
},
dayClick: function(date, jsEvent, view) {
today = new Date();
selected_date = new Date(date.format() + "GMT -0500");
selected_date.setHours(0,0,0,0);
today.setHours(0,0,0,0);
if (selected_date.getTime() >= today.getTime()) {
new_ticket(date.format());
}else{
}
},
eventRender: function(event,element){
title = "";
var start_date = new Date(event.start);
var start_hour = start_date.getHours() % 12 || 12;
var start_minute = (start_date.getMinutes()<10?'0':'') + start_date.getMinutes()
var start_ampm = (start_hour >= 12) ? "PM" : "AM";
var start_date = start_hour + ":" + start_minute + "" + start_ampm;
title = start_date;
if (event.end != "") {
var end_date = new Date(event.end);
var end_hour = end_date.getHours() % 12 || 12;
var end_minute = (end_date.getMinutes()<10?'0':'') + end_date.getMinutes()
var end_ampm = (end_hour >= 12) ? "PM" : "AM";
var end_date = end_hour + ":" + end_minute + "" + end_ampm;
title = title + " - " + end_date;
};
element.find('.fc-content').parent().html(title + " - " + event.title);
}
});
add_event(333,"February 02, 2015 00:00 -0500","February 06, 2015 09:00 -0500","Prueba concepto","#5cb85c")
add_event(334,"February 02, 2015 00:00 -0500","February 06, 2015 08:59 -0500","Prueba concepto 2","#5cb85c")
});
function add_event(id,start,end,title,backgroundColor){
var eventObject = new Object();
eventObject.className = 'calendar_event'
eventObject.id = id;
eventObject.start = start;
eventObject.end = end;
eventObject.title = title;
eventObject.backgroundColor = backgroundColor;
eventObject.borderColor = "white";
eventObject.allDay = false;
$('#calendar').fullCalendar('renderEvent',eventObject,true);
}
function new_ticket(date){
$.get('/tickets/new',{date: date},function(data){
$("#modal_form_container").html(data);
$("#modal_form").modal('show');
});
}
function show_ticket_details(ticket_id){
$.get('/tickets/' + ticket_id,function(data){
$("#modal_form_container").html(data);
$("#modal_form").modal('show');
});
}
编辑 2:这是我的周视图,如您所见,它在此视图中工作正常。
查看完整的日历代码我发现了这个属性:
nextDayThreshold: '09:00:00', // 9am
你可能想修改这个。
http://fullcalendar.io/docs/event_rendering/nextDayThreshold/
When an event's end time spans into another day, the minimum time it must be in order for it to render as if it were on that day.
... .
Only affects timed events that appear on whole-days. Whole-day cells occur in month view ...
所以我遇到了以下问题: 正如您在屏幕截图中看到的,我添加了 2 个相差 1 分钟的事件。两个事件都在同一 Date/Time 开始,但一个在 08:59 AM 结束,另一个在 09:00 AM(同一天)结束,为什么月视图呈现这样?
我怀疑我应该在月视图中设置一个 first_our_of_day 参数,但我在文档中没有看到类似的内容。
编辑:
这是我的代码:
var calendar;
$(document).ready(function() {
calendar = $('#calendar').fullCalendar({
// eventLimit: true,
axisFormat: 'h:mm T',
header:{
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
eventClick: function(calEvent, jsEvent, view) {
event_id = calEvent.id;
show_ticket_details(event_id);
},
dayClick: function(date, jsEvent, view) {
today = new Date();
selected_date = new Date(date.format() + "GMT -0500");
selected_date.setHours(0,0,0,0);
today.setHours(0,0,0,0);
if (selected_date.getTime() >= today.getTime()) {
new_ticket(date.format());
}else{
}
},
eventRender: function(event,element){
title = "";
var start_date = new Date(event.start);
var start_hour = start_date.getHours() % 12 || 12;
var start_minute = (start_date.getMinutes()<10?'0':'') + start_date.getMinutes()
var start_ampm = (start_hour >= 12) ? "PM" : "AM";
var start_date = start_hour + ":" + start_minute + "" + start_ampm;
title = start_date;
if (event.end != "") {
var end_date = new Date(event.end);
var end_hour = end_date.getHours() % 12 || 12;
var end_minute = (end_date.getMinutes()<10?'0':'') + end_date.getMinutes()
var end_ampm = (end_hour >= 12) ? "PM" : "AM";
var end_date = end_hour + ":" + end_minute + "" + end_ampm;
title = title + " - " + end_date;
};
element.find('.fc-content').parent().html(title + " - " + event.title);
}
});
add_event(333,"February 02, 2015 00:00 -0500","February 06, 2015 09:00 -0500","Prueba concepto","#5cb85c")
add_event(334,"February 02, 2015 00:00 -0500","February 06, 2015 08:59 -0500","Prueba concepto 2","#5cb85c")
});
function add_event(id,start,end,title,backgroundColor){
var eventObject = new Object();
eventObject.className = 'calendar_event'
eventObject.id = id;
eventObject.start = start;
eventObject.end = end;
eventObject.title = title;
eventObject.backgroundColor = backgroundColor;
eventObject.borderColor = "white";
eventObject.allDay = false;
$('#calendar').fullCalendar('renderEvent',eventObject,true);
}
function new_ticket(date){
$.get('/tickets/new',{date: date},function(data){
$("#modal_form_container").html(data);
$("#modal_form").modal('show');
});
}
function show_ticket_details(ticket_id){
$.get('/tickets/' + ticket_id,function(data){
$("#modal_form_container").html(data);
$("#modal_form").modal('show');
});
}
编辑 2:这是我的周视图,如您所见,它在此视图中工作正常。
查看完整的日历代码我发现了这个属性:
nextDayThreshold: '09:00:00', // 9am
你可能想修改这个。
http://fullcalendar.io/docs/event_rendering/nextDayThreshold/
When an event's end time spans into another day, the minimum time it must be in order for it to render as if it were on that day. ... . Only affects timed events that appear on whole-days. Whole-day cells occur in month view ...