jQuery FullCalendar click 'next' event notificatin

前端 未结 3 670
我寻月下人不归
我寻月下人不归 2020-12-21 11:18

How can i get notified when the user click on \'next\' (arrow) ? I\'m using the calendar in month view and I want to load the next month data on demand. Also, do smbdy has a

相关标签:
3条回答
  • 2020-12-21 11:25

    Your way of approaching is wrong. You may need to write an API which returns the list of calendar objects in JSON, and use the following options.

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

    Then, fullcalendar will automatically call /myfeed.php whenever it needs. e.g. If a user clicks 'prev' or 'next' month button.

    Here's the example URL fullcalendar will generate :

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

    For more information, please visit the following URL. http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/

    0 讨论(0)
  • 2020-12-21 11:35

    Here the viewDisplay function is called when the user clicks next/prev. Also, you can see that is is getting the next lot of data via AJAX. I hope this helps :)

    $(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;
    }
    
    0 讨论(0)
  • 2020-12-21 11:47

    you can use the viewDisplay trigger (http://arshaw.com/fullcalendar/docs/display/viewDisplay/) but that gets called also when the calendar loads, or the user switches views.

    it sounds like you'd want an events function instead: http://arshaw.com/fullcalendar/docs/event_data/events_function/

    for the asp.net thing, have you looked here? http://weblogs.asp.net/gunnarpeipman/archive/2010/02/03/using-fullcalendar-jquery-component-with-asp-net-mvc.aspx

    0 讨论(0)
提交回复
热议问题