我尝试在jquery fullcalendar中存储基于dayClick事件的记录。根据consol日志,日期提供为: locale:Object,_d:Date 2015-03-19T00:00: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);
},
答案 0 :(得分:1)
试
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);
}
}
}
});