views:

50

answers:

3

If I specify my events by hardcoding in a javascript events array, the time is displayed before the title on the calendar:

The Javascript code of:

events: [ { title : "my title", start : new Date(2010,9,8,11,12) } ]

results in a display of "11:12 my title" as an event on my calendar.

But, when I use an function to create the events (receiving the data via ajax), the time isn't displayed on the calendar. Here is the code for the ajax success function (in this example, I've hardcoded the start date, but it doesn't matter how I set the start date, it is never displayed, only the title is displayed):

        success: function(doc) {

            var events = [];

            $(doc).find('event').each(function() {
                events.push({
                    title: $(this).find('title').text(),
                    start: new Date(2010,9,8,11,12),
                    url:   $(this).find('url').text(),
                    className: $(this).find('className').text(),
                    allDay:    $(this).find('allDay').text()
                });
            });

            callback(events);
        }

It appears that the start date is handled differently thru the events function. I've tried using "new Date()" or specifying the date as a string (October 7 2010, 14:10) or as a unix time stamp. It appears to recognize the date because the event appears on the proper day of the calendar, but the time doesn't display when I am using the ajax function.

Any ideas?

Thanks

A: 

It could be the allDay option. Maybe try passing allDay: false, and see what happens. No quotes around false, of course.

orolo
A: 

It appears that if I pass the start string in the format "October 8, 2010, 13:13" and then pass that to the event object without changing it, that the time is displayed. I'm not totally done but it appears that this works.

Don
A: 

Perhaps with formatDate :

success: function(doc) { 

            var events = []; 

            $(doc).find('event').each(function() { 
                events.push({ 
                    title: $(this).find('title').text(), 
                    start: $.fullCalendar.formatDate( new Date(2010,9,8,11,12),  'yyyy-MM-dd HH:mm:ss'), 
                    url:   $(this).find('url').text(), 
                    className: $(this).find('className').text(), 
                    allDay:    $(this).find('allDay').text() 
                }); 
            }); 

            callback(events); 
        } 
Eureka