我试图在jquery fullcalendar中存储一个基于dayClick事件的记录。根据控制台日志,日期如下:locale:Object,_d:Date 2015-03-19T00:00.000Z,然后我将其传递给ce.start和ce.end,当我检查数据库时,我在calevnt.start和calevent.end中的值为"无效日期"--这里出了什么问题?
在客户端:
Template.calendar.helpers({
options: function() {
return {
lang: 'de',
dayClick:function(date,allDay,jsEvent,view){
var ce = {};
ce.start = date;
ce.end = date;
ce.color = 'red';
ce.className = 'todo';
ce.project = Session.get('active_project');
ce.title = ' Jour Fixe2';
ce.owner = Meteor.userId;
console.log(date,allDay,jsEvent,view);
Meteor.call('addCalEvent',ce);
}
}
}
});
在服务器上:
'addCalEvent': function (calevent) {
if (!calevent.type) {
calevent.type = 'milestone';
}
return Calevents.insert(calevent);
},
尝试
Template.calendar.helpers({
options: function() {
return {
selectable: true,
selectHelper: true,
lang: 'de',
select: function(start, end, allDay) {
var ce = {};
ce.start = start.format(); // return moment date
ce.end = end.format(); // return moment date
ce.color = 'red';
ce.className = 'todo';
ce.project = Session.get('active_project');
ce.title = ' Jour Fixe2';
ce.owner = Meteor.userId;
console.log(start, end);
Meteor.call('addCalEvent',ce);
}
}
}
});