jQuery日历:如何在特定日期添加可点击事件?

我正在使用jquery完整日历http://arshaw.com/fullcalendar来显示会议。

我只想确认它是否可以添加一个事件(让我们创建一个新的会议

使用php ajax)在特定日期使用此function。?

我已经广泛使用了fullcalendar,是的,在特定日期添加事件是它的核心function。 您需要了解事件对象结构(请参阅http://arshaw.com/fullcalendar/docs/event_data/Event_Object/ ),特别是将start设置为开始日期/时间的unix时间戳,并将其标记为全天事件allDay = "true"或设置end时间戳。

正如您提到的Ajax,使用事件填充日历的一种方法是通过JSON加载它们,您可以这样做:

$('#calendar').fullCalendar({ events: '/myfeed.php' });

使用myfeed.php返回一个充满事件对象的json结构。


以下是如何使用各种选项设置日历的完整示例

 //Initialise the calendar $('#calendar').fullCalendar({ header: { left: 'title', center: '', right: 'today agendaDay,agendaWeek,month prev,next'}, editable: true, showTime: true, allDayDefault: false, defaultView: 'agendaDay', firstHour: 8, eventColor: '#23478A', eventBorderColor:'#000000', eventTextColor:'#ffffff', //eventBackgroundColor:, theme: true, //enables jquery UI theme eventSources: [ '/myfeed.php' ], //this is when the event is dragged and dropped somewhere else eventDrop: function(event,dayDelta,minuteDelta,allDay,revertFunc) { //do something... }, //this is when event is resized in day/week view eventResize: function(event,dayDelta,minuteDelta,revertFunc) { //do something }, eventClick: function(calEvent, jsEvent, view) { //do something }, eventRender: function( event, element, view ) { //redo the title to include the description element.find(".fc-event-title").html(event.title + ": " + event.description + ""); }, loading: function(bool) { if (bool) { $("#loading").show(); } else { $('#loading').hide(); } } }); 

我假设您想要在用户点击一天(在月视图中)或时间段(在日/周视图中)时添加事件。 如果是这样,您可以使用selecteventClick回调在日历上添加和获取事件。

检查这个小提琴: http : //jsfiddle.net/100thGear/xgSTr/

这将jQuery UI对话框合并到FullCalendar中,并且为了方便起见,还将所选日期inheritance到jQuery UI datepicker中!

如果这有帮助,请告诉我。