JSFiddle - React, Tailwind, and code Playground

by Felype Rennan

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.css" />


<div id="calendar"></div>

JavaScript

a = [
        {
            title: 'Event1',
            start: '2013-09-23'
        },
        {
            title: 'Event2',
            start: '2013-09-24'
        }
        // etc...
    ];


const ignoreCircularJsonStringify = (o) => {
	// Almost as seen in stackoverflow.com/questions/11616630
	var cache = [];
	let retv = JSON.stringify(o, (key, value) => {
		if (typeof value === 'object' && value !== null) {
			if (cache.indexOf(value) !== -1) {
				// Circular reference found, discard key
				return;
			}
			// Store value in our collection
			cache.push(value);
		}
		return value;
	});
	cache = null;
	
	return retv;
}

console.log("before I added to the calendar a as a source "+JSON.stringify(a));

$("#calendar").fullCalendar({
			  events: a,
			header : {
				left : 'title',
				center : '',
				right : 'today prev,next'
			},
			editable : false
		});

console.log("after I added to the calendar a as a source. It went wrong ");

console.log(ignoreCircularJsonStringify(a));