Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm using fullcalendar and everything looks good except after calling toJSON to serialize the data. The dates, which are formatted like "Wed 29, June" etc., becomes "start: {}" which is not what I need. What am I missing?

Any idea why it's turning date's into {}?

Here is the script:

C#
// first the calendar
$(document).ready(function() {
$('#calendar').fullCalendar({
    dayClick: function(date, allDay, jsEvent, view) {

        $(this).css('background-color', 'red');
    },
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },

    aspectRatio: 1.5,
    editable: true,
        events: "/Calendar/CalendarData"
    });
});


The date looks good in the event, but after toJSON call, the dates get converted to {}.

Here is the toJSON call:

C#
var event = $('#calendar').fullCalendar('clientEvents');

var jlst = $.toJSON(event);

$.post("/Calendar/AddCalendar", { jsonData: jlst },
    function(data, textStatus) {
        if (textStatus != "success") {
        result = "false";
    }
});



Here is what the date looks like before call to toJSON:

CSS
"Wed Jun 23 2010 06:00:00 GMT-0400 (Eastern Daylight Time) {}"


Here is the serialized data. Note the start and end fields have changed:

CSS
"[{\"id\":\"69cf0853-40e3-4d29-8dc6-9d8b83e9696d\",
\"title\":\"Second Schedule",
\"start\":{},
\"end\":{},
\"allDay\":false,
\"_id\":\"69cf0853-40e3-4d29-8dc6-9d8b83e9696d\",
\"_start\":{},
\"_end\":{},
\"className\":[],
\"source\":\"/Calendar/CalendarData\"}]"


Any tips will be much appreciated. Thanks.
Posted
Updated 2-Jul-10 10:10am
v3

1 solution

You have curly braces in your date string. {} is Javascript shorthand for:

var obj = new Object();

var obj1 = {};


Both produce new Object types. Remove the Curly braces from your date string and try again. :)
 
Share this answer
 
Comments
Manfred Rudolf Bihy 31-May-11 17:35pm    
Good catch! 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900