使用Jquery将事件动态插入Fullcalendar [英] Insert event dynamically to Fullcalendar using Jquery

查看:402
本文介绍了使用Jquery将事件动态插入Fullcalendar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用Jquery向fullCalendar添加新事件。我使用Eclipse来开发网页,并且完全不熟悉Ajax,而且它不适用于我的eclipse。



所有东西都写在button.click函数中jquery。

  var subject = $(#txtEventName)。val(); //事件的标题
var dateStart = $(#txtDate)。val(); //事件发生的日子
var dateEnd = $(#txtDateEnd)。val(); //事件结束的那一天
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; //它的日期字符串
event.end = dateEnd; //它的日期字符串。
event.color =blue;
event.allDay = false;

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

未检测到错误,但未创建事件。
PS:如果在jQuery中没有其他方法,我想继续使用数组feed。

解决方案

试试这个: / p>

  var newEvent = new Object(); 

newEvent.title =一些文字;
newEvent.start = new Date();
newEvent.allDay = false;
$('#calendar')。fullCalendar('renderEvent',newEvent);

请注意,当您将值分配给开始,它需要使用其中一种支持的格式。



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


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.

解决方案

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.

这篇关于使用Jquery将事件动态插入Fullcalendar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆