完整的日历传递周首次到控制器 - 移动下周jquery

时间:2015-08-24 11:04:58

标签: jquery html fullcalendar

我的视图中有完整的日历。我想在转到上一周/下周时将周开始日期传递给控制器​​。我把我的jquery包括在内:

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

       events: function (start, end, callback) {
           $.get('events/get', function (result) {
               callback(result);
           });
 var cDate = new Date(); var Cyear = cDate.getFullYear(); year = Cyear;
           var Sun = $('#calendar').find(".fc-sun").text(); d1 = Sun; SelectDate = Sun + "/" + year; 
       }
   });

 $('#btnPrev').click(function () {
        $('#calendar').fullCalendar('prev');
        $.ajax({
            type: "POST",
            url: '/Timesheet/Index',
            data: SelectDate            
        });
    });
    $('#btnNext').click(function () {
        $('#calendar').fullCalendar('next');
        //$.ajax({
        //    type: "POST",
        //    url: "/Timesheet/Index?SelectDate=" + SelectDate,
        //    success: function (data) {

        //    },
        //    error: function () {

        //    }
        //});
    });

如何将此传递给控制器​​?

1 个答案:

答案 0 :(得分:2)

我可以使用以下代码在日历中移动next / prev周:

$('.fc-prev-button').click(function () {
        startDate = $('#calendar').fullCalendar('getDate').startOf('week');       
        window.location.href = "/TimesheetModels/EmpTimesheet?selectDate=" + convertDate(startDate);
    });

    $('.fc-next-button').click(function () {;
        startDate = $('#calendar').fullCalendar('getDate').startOf('week');        
        window.location.href = "/TimesheetModels/EmpTimesheet?selectDate=" + convertDate(startDate);
    });