我正在使用FullCalendar来制作调度程序。我似乎无法向我的mysql数据库添加任何事件,因为我收到错误:
未捕获的TypeError:undefined不是函数。
Chrome正在突出显示以下内容:
var start = $.fullCalendar.formatDate(start, "yyyy-MM-dd HH:mm:ss");
任何想法为什么?我有fullCalendar v 2.1.1。引用得当。
这是完整的脚本。
//do all the calendar stuff for adding a new appt.
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $("#calendar").fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
slotDuration: '00:10:00',
defaultView: 'agendaWeek',
draggable: true,
events: 'json_appointments.php',
eventRender: function(event, element, view) {
if (event.allDay == true) {
event.allDay = true;
} else {
event.allDay = false;
}
},
eventClick: function(event, jsEvent, view) {
$('#modalTitle').html(event.title);
$('#modalBody').html(event.reason + ' ' + event.pre_notes);
$('#fullCalModal').modal();
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
},
selectable: true,
selectHelper: true,
select: function(start, end, allDay) {
var title = prompt('Event Title:');
if (title) {
var start = $.fullCalendar.formatDate(start, "yyyy-MM-dd HH:mm:ss");
var end = $.fullCalendar.formatDate(end, "yyyy-MM-dd HH:mm:ss");
$.ajax({
url: 'ajax_add_appt.php',
data: 'title='+ title+'&start='+ start +'&end='+ end,
type: "POST",
success: function(json) {
alert('Added Successfully');
}
});
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay
},
true // make the event "stick"
);
}
calendar.fullCalendar('unselect');
},
eventDrop: function(event, delta) {
var start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
var end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
$.ajax({
url: '',
data: 'title='+ event.title+'&start='+ start +'&end='+ end +'&id='+ event.id ,
type: "POST",
success: function(json) {
alert("Updated Successfully");
}
});
},
eventResize: function(event) {
var start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
var end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
$.ajax({
url: 'http://localhost:8888/fullcalendar/update_events.php',
data: 'title='+ event.title+'&start='+ start +'&end='+ end +'&id='+ event.id ,
type: "POST",
success: function(json) {
alert("Updated Successfully");
}
});
}
});
答案 0 :(得分:1)
感谢您的评论。我确实引用了moment.js。
我只需要像这样编辑我的脚本:
var start=moment(start).format('YYYY-MM-DDTHH:mm:ssZ');
var end=moment(end).format('YYYY-MM-DDTHH:mm:ssZ');
...基于Alvaro提到的其他堆栈链接。谢谢。