Thursday, September 19, 2013

jquery fullcalendar how to serialize events

jquery fullcalendar how to serialize events

I use fullcalendar jquery plugin from http://arshaw.com/fullcalendar/ and
I use knockout js on my website.
I added the event array what is the source of the calendar. The user can
modify the events (array).
Then I want to serialize the event array, send by ajax, but I can not,
because the calendar modifies my array, and puts an cycle into the source
array. How can I remove the changes. Why is there a cycle in my array? I
read, may be there is an DOM object in this.
Chrome sendrequest error: TypeError: Converting circular structure to JSON
var a = [];
a.push({
title : 'Event2',
start : '2013-09-05'
});
a.push({
title : 'Event2',
start : '2013-09-15'
});
$("#calendar").fullCalendar({
events : a,
header : {
left : 'title',
center : '',
right : 'today prev,next'
},
editable : false,
});
console.log(JSON.stringify(a));
TypeError: Converting circular structure to JSON
How can I fix it? What is the cause of the cycle?

1 comment:

  1. The plugin is modifying your data.

    If you run:

    console.log(a)
    before your console.log you can see the issue. One solution is to only return the fields you need, and not return the fields which have cyclical recursions.
    khanhvuongtuan1@gmail.com - Working at ComponentPro

    ReplyDelete