jQuery FullCalendar单击“下一步”事件通知

时间:2010-02-08 03:24:50

标签: asp.net jquery ajax fullcalendar

当用户点击“下一步”(箭头)时,如何收到通知? 我在月视图中使用日历,我想按需加载下个月的数据。 另外,smbdy有一个使用ASP.NET(AJAX调用)数据的例子吗?

3 个答案:

答案 0 :(得分:3)

您可以使用viewDisplay触发器(http://arshaw.com/fullcalendar/docs/display/viewDisplay/),但在日历加载或用户切换视图时也会调用它。

听起来你想要一个事件功能http://arshaw.com/fullcalendar/docs/event_data/events_function/

对于asp.net的事情,你看过这里吗? http://weblogs.asp.net/gunnarpeipman/archive/2010/02/03/using-fullcalendar-jquery-component-with-asp-net-mvc.aspx

答案 1 :(得分:1)

你接近的方式是错误的。您可能需要编写一个以JSON格式返回日历对象列表的API,并使用以下选项。

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

然后,fullcalendar会在需要时自动调用/myfeed.php。 例如如果用户点击“上一个”或“下个月”按钮。

以下是fullcalendar将生成的示例网址:

/myfeed.php?start=1262332800&end=1265011200&_=1263178646

有关详细信息,请访问以下网址。 http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/

答案 2 :(得分:0)

当用户单击next / prev时,将调用viewDisplay函数。此外,您可以看到通过AJAX获取下一批数据。 我希望这会有所帮助:)

$(document).ready(function () {

var calendar = $('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'resourceMonth'
    },
    defaultView: 'resourceWeek',


    eventSources: [ getCalData() ],
    header: {
        left: 'prev,next today',
        center: 'title',
        right: ''
    },
    viewDisplay: function (view) {
        $('#calendar').fullCalendar('removeEvents');
        $('#calendar').fullCalendar('addEventSource', getCalData());
        $('#calendar').fullCalendar('rerenderEvents');
    }
  });
});


function getCalData() {

var source = [{}];
$.ajax({
    async: false,
    url: '/mysite/GetWeekData',
    data: { myParam: $('#calendar').fullCalendar('getView').visStart },
    success: function (data) {
        $(data).each(function () {
            source.push({
                title: $(this).attr('title'),
                start: $(this).attr('start'),
            });
        });
    },
    error: function () {
        alert('could not get the data');
    },
});
return source;
}