fullCalendar动态eventClick行为

时间:2013-12-17 08:04:50

标签: javascript php jquery fullcalendar

我正在为我的事件源使用带有2个JSON源的fullCalendar。我正在使用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())
    });
  }
});

1 个答案:

答案 0 :(得分:1)

如文档中所示,您可以拥有自己的非标准字段,我们可以在其中包含任意信息,在我们的示例中,我们可以存储事件所属的位置。

$('#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