Insert an event dynamically in Fullcalendar using jQuery

I'm having trouble adding a new event to fullCalendar using jQuery. I use Eclipse to develop a web interface and are not familiar with Ajax at all and without it, this does not work with my eclipse.

Everything is written inside the button.click function in jquery.

var subject = $("#txtEventName").val();  //the title of the event           
var dateStart = $("#txtDate").val();     //the day the event takes place
var dateEnd = $("#txtDateEnd").val();    //the day the event finishes
var allDay = $("#alldayCheckbox").val(); //true: event all day, False:event from time to time           

var events=new Array();     
event = new Object();       
event.title = subject; 
event.start = dateStart;    // its a date string
event.end = dateEnd;        // its a date string.
event.color = "blue";
event.allDay = false;

events.push(event);
$('#calendar').fullCalendar('addEventSource',events);

No errors were detected, but no event was generated. PS: I would like to stay with an array if there is no other way in jQuery.

+5
source share
1 answer

Try the following:

var newEvent = new Object();

newEvent.title = "some text";
newEvent.start = new Date();
newEvent.allDay = false;
$('#calendar').fullCalendar( 'renderEvent', newEvent );

Please note that when you assign a start value , it must be in one of the supported formats.

IETF (: Wed, 18 Oct 2009 13:00:00 EST), ISO8601 (: 2009-11-05T13:15:30Z) UNIX.

+12

All Articles