Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read property '_calendar' of undefined in moment.js

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)

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);
                        }
                    });

Stack Trace

like image 791
rapid3642 Avatar asked Sep 03 '17 19:09

rapid3642


2 Answers

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},
like image 64
JimM Avatar answered Oct 21 '22 23:10

JimM


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');
like image 33
Kaushik Makwana Avatar answered Oct 22 '22 01:10

Kaushik Makwana