laravel 无法读取 moment.js 中未定义的属性“_calendar”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46026957/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot read property '_calendar' of undefined in moment.js
提问by rapid3642
I am getting an error when someone is trying to submit an event on their calendar to be saved to the server. Any help is appreciated, thank you for your time! Please let me know if you guys are needing anymore specific information.
当有人尝试提交日历上的事件以保存到服务器时,我收到错误消息。任何帮助表示赞赏,感谢您的时间!如果你们需要更多具体信息,请告诉我。
UPDATE: It seems that when I switched from pushing to an array myself when a event is added to the calendar via the drop feature from fullcalendar, then it works ok but I had issues with that code so I used clientevents from fullcalendar instead and now I am getting this error. Any ideas on what a fix might be for this?
更新:似乎当我通过 fullcalendar 的 drop 功能将事件添加到日历时,我自己从推送到数组切换,然后它工作正常,但我遇到了该代码的问题,所以我改用了 fullcalendar 中的 clientevents,现在我我收到这个错误。关于修复可能是什么的任何想法?
I am getting the following error:
我收到以下错误:
Uncaught TypeError: Cannot read property '_calendar' of undefined at D (moment.min.js:6) at e (jquery-1.11.3.min.js:5) at Vb (jquery-1.11.3.min.js:5) at Vb (jquery-1.11.3.min.js:5) at Vb (jquery-1.11.3.min.js:5) at Function.m.param (jquery-1.11.3.min.js:5) at Function.ajax (jquery-1.11.3.min.js:5)
at Object. (calendar:514) at Function.each (jquery-1.11.3.min.js:2) at Object.success (calendar:500)
未捕获的类型错误:无法在 Vb(jquery-1.11.3.min.js: 5) 在 Vb (jquery-1.11.3.min.js:5) 在 Vb (jquery-1.11.3.min.js:5) 在 Function.m.param (jquery-1.11.3.min.js:5) ) 在 Function.ajax (jquery-1.11.3.min.js:5)
在 Object。(calendar:514) at Function.each (jquery-1.11.3.min.js:2) at Object.success (calendar:500)
companyCalendar.blade.php
companyCalendar.blade.php
var emailContainer = {};
emailContainer.email = email;
console.log("AJAX call here to submit dropped events as guest.");
$.ajax({
type: "POST",
url: '/partialAccountCheck',
data: emailContainer,
success: function (data) {
console.log('success, proceed with adding events to the company calendar');
$.each(newEvents, function (i, event) {
if (event.title !== 'undefined' && event.title !== null && event.title !== undefined) {
console.log(JSON.stringify(event));
event.start = moment(event.start).toDate();
event.end = moment(event.end).toDate();
event.start = formatDate(event.start) + ' ' + event.start.getHours() + ':' + event.start.getMinutes() + ':00';
event.end = formatDate(event.end) + ' ' + event.end.getHours() + ':' + event.end.getMinutes() + ':00';
console.log('event start is: ' + event.start);
console.log('event end is: ' + event.end);
event.identifier = <?php echo json_encode($companyIdentifier) ?>;
event.email = email;
event.services = event.title;
event.startAppointmentTime = event.start;
event.endAppointmentTime = event.end;
console.log("AJAX call here adding dropped appointments as guest.");
$.ajax({
type: "POST",
url: 'submitCalendarEvent',
data: event,
success: function (data) {
console.log('success');
},
complete: function (data) {
console.log(data);
}
});
} else {
console.log('exclude from submission');
}
});
},
complete: function (data) {
console.log(data);
}
});
回答by JimM
I solved the problem creating variables for event.start and event.end.
我解决了为 event.start 和 event.end 创建变量的问题。
start=moment(event.start).format('Y-MM-DD HH:mm:ss');
end=moment(event.end).format('Y-MM-DD HH:mm:ss');
$.ajax({
url:"insert.php",
type:"POST",
data:{title:event.title, start:start, end:end},
回答by Kaushik Makwana
you need to convert your date from date
format to string
.
您需要将日期从date
格式转换为string
.
event.start = moment(event.start).format('YYYY-MM-DD HH:mm:00');
event.end = moment(event.end).format('YYYY-MM-DD HH:mm:00');