使用Jquery将事件动态插入Fullcalendar

前端之家收集整理的这篇文章主要介绍了使用Jquery将事件动态插入Fullcalendar前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我无法使用Jquery向fullCalendar添加新事件.我正在使用Eclipse来开发web并且根本不熟悉Ajax,而且它与我的eclipse不兼容.

所有内容都写在jquery中的button.click函数中.

  1. var subject = $("#txtEventName").val(); //the title of the event
  2. var dateStart = $("#txtDate").val(); //the day the event takes place
  3. var dateEnd = $("#txtDateEnd").val(); //the day the event finishes
  4. var allDay = $("#alldayCheckBox").val(); //true: event all day,False:event from time to time
  5. var events=new Array();
  6. event = new Object();
  7. event.title = subject;
  8. event.start = dateStart; // its a date string
  9. event.end = dateEnd; // its a date string.
  10. event.color = "blue";
  11. event.allDay = false;
  12. events.push(event);
  13. $('#calendar').fullCalendar('addEventSource',events);

没有检测到错误,但未创建事件.
P.S:如果jQuery中没有其他方法,我想继续使用数组Feed.

最佳答案
@H_502_16@试试这个:

  1. var newEvent = new Object();
  2. newEvent.title = "some text";
  3. newEvent.start = new Date();
  4. newEvent.allDay = false;
  5. $('#calendar').fullCalendar( 'renderEvent',newEvent );

请注意,当您将值分配给start时,它需要采用其中一种受支持的格式.

您可以指定IETF格式的字符串(例如:Wed,2009年10月18日13:00:00 EST),ISO8601格式的字符串(例如:2009-11-05T13:15:30Z)或UNIX时间戳.

猜你在找的jQuery相关文章