Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

moment().format() and fullcalendar: undefined is not a function

I'm trying to use moment().format() with fullcalendar; I have this code:

<script src="<?php echo ASSETS_URL; ?>/js/plugin/fullcalendar/lib/moment.js"></script>
<script> moment().format() </script> 
<script type="text/javascript">
 $('#calendar').fullCalendar({

        header: hdr,
        buttonText: {
            prev: '<i class="fa fa-chevron-left"></i>',
            next: '<i class="fa fa-chevron-right"></i>'
        },
        defaultView: "agendaWeek",
        editable: true,
        droppable: false, // this allows things to be dropped onto the calendar !!!
        lang: 'it',
        timeFormat: 'H(:mm)',
        firstDay: 1,
        drop: function (date, allDay) { // this function is called when something is dropped


        events: [{

        }],
        eventDragStart: function( event, jsEvent, ui, view ) { 
            ev_start=event.start.moment().format("dddd (d) DDD - D/MM/YY");
            console.log(ev_start);
            },

        },

When I drag an element from calendar there is this error: Uncaught TypeError: undefined is not a function

I done some debug and the error is caused by moment().format() Anyone could help me?

like image 677
Joe Avatar asked Sep 05 '14 08:09

Joe


1 Answers

If you receive that error on that line, check your moment.js file is good.

Then, this line is wrong:

ev_start=event.start.moment().format("dddd (d) DDD - D/MM/YY");

If event.start it's a timedate you should do this:

ev_start = moment(event.start).format("dddd (d) DDD - D/MM/YY");
like image 66
michelem Avatar answered Sep 22 '22 16:09

michelem