最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Cannot read property '_calendar' of undefined in moment.js - Stack Overflow

programmeradmin6浏览0评论

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?

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)

panyCalendar.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 pany 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($panyIdentifier) ?>;
                                    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');
                                        },
                                        plete: function (data) {
                                            console.log(data);
                                        }
                                    });
                                } else {
                                    console.log('exclude from submission');
                                }
                            });
                        },
                        plete: function (data) {
                            console.log(data);
                        }
                    });

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?

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)

panyCalendar.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 pany 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($panyIdentifier) ?>;
                                    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');
                                        },
                                        plete: function (data) {
                                            console.log(data);
                                        }
                                    });
                                } else {
                                    console.log('exclude from submission');
                                }
                            });
                        },
                        plete: function (data) {
                            console.log(data);
                        }
                    });

Share Improve this question edited Sep 5, 2017 at 17:46 rapid3642 asked Sep 3, 2017 at 19:07 rapid3642rapid3642 9132 gold badges14 silver badges27 bronze badges 1
  • 3 I have met the same error as yours the last found the solution Try start.calendar() or start.format("YYYY-MM-DD"); (or something similar) instead of start by stackoverflow./a/24729448 – SRENG Khorn Commented Sep 12, 2017 at 3:34
Add a ment  | 

2 Answers 2

Reset to default 9

you need to convert your date from date format to 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');

I solved the problem creating variables for event.start and 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},
发布评论

评论列表(0)

  1. 暂无评论