Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert event dynamically to Fullcalendar using Jquery

I am having trouble to add new event to fullCalendar using Jquery. I am using Eclipse to develop web and not familiar with Ajax at all and aperantly, it does not work with my eclipse.

Everything is written inside a 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 bugs were detected but the event is not created. P.S: I would like to stay with array feed if no other way in jQuery.

like image 944
Ori Refael Avatar asked Jun 16 '12 12:06

Ori Refael


1 Answers

Try this:

var newEvent = new Object();

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

Note that when you assign value to start it needs to be in one of the supported formats.

You may specify a string in IETF format (ex: Wed, 18 Oct 2009 13:00:00 EST), a string in ISO8601 format (ex: 2009-11-05T13:15:30Z) or a UNIX timestamp.

like image 190
Adil Malik Avatar answered Nov 05 '22 09:11

Adil Malik