Insert event dynamically to Fullcalendar using Jquery

大憨熊 提交于 2019-12-21 04:39:14

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/11063568/insert-event-dynamically-to-fullcalendar-using-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!