我将fullCalendar与2个JSON提要一起用于事件源。单击事件时,我正在使用eventClick打开模式窗口。但是,我只需要第一个事件源(json-events.php)的模式窗口。我希望第二个来源(json-paidstaff.php)中的所有事件都只是没有eventClick函数的静态框。有什么方法可以只为一个来源指定eventClick吗?
我的js目前
$('#calendar').fullCalendar({
editable: false,
timeFormat: 'H(:mm)', // uppercase H for 24-hour clock
eventSources: [
// your event source
{
url: 'json-events.php?uid=$bbuserinfo[userid]'
},
// any other sources...
{
url: 'json-paidstaff.php?uid=$bbuserinfo[userid]',
color: 'black', // a non-ajax option
textColor: 'white' // a non-ajax option
}
],
eventRender: function (event, element) {
element.find('.fc-event-title').append("<br/>" + event.namescreds);
},
loading: function (bool) {
if (bool) $.blockUI();
else $.unblockUI();
},
eventClick: function (calEvent, jsEvent, view) {
$.blockUI();
Boxy.load('ajax.php?uid=$bbuserinfo[userid]&id=' + calEvent.id, {
modal: true,
closeable: true,
afterShow: ($.unblockUI())
});
}
});
最佳答案
如文档中所给,您可以拥有自己的非标准字段,在这里我们可以获取任何任意信息,在本例中,我们可以存储事件所属的位置。
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
events: [{
"id": 1,
"title": "Hello World",
"start": "Wed, 15 Jan 2014 09:00:00",
"end": "Wed, 15 Jan 2014 10:00:00",
"belongsto" : "list 1"
}, {
"id": 2,
"title": "Good Afternoon",
"start": "Wed, 23 Jan 2014 13:00:00",
"end": "Wed, 23 Jan 2014 17:00:00",
"belongsto" : "list 2"
}],
eventClick: function(calEvent, jsEvent, view) {
alert(calEvent.belongsto);
if(calEvent.belongsto === "list 1") {
//do something.
}
}
});
DEMO