如何在jQuery完整日历中选择月份?

Pus*_*raj 15 javascript php jquery fullcalendar

我们使用jQuery完整日历来显示来自数据库的事件.

我需要根据用户选择的月份在日历下方显示事件onchange.我可以根据事件日期获取数据,但我无法在jQuery日历中获得用户选择的月份.

$('#calendar').fullCalendar({
    theme: true,
    header: {

        left: 'today',
        center: 'prevYear,prev,title, next,nextYear',
        right: ' month,agendaWeek,agendaDay'
    },
    buttonText: {
        prevYear: 'Prev'
    },
    editable: false,
    events: [
    <?php foreach ($edumeet_invite_det as $key =>  $edumeet_det): ?> 
    <?php $edumeet_start = $edumeet_det->getFromDate(); ?>
    <?php $edumeet_end = $edumeet_det->getToDate(); ?>
    <?php $title = $edumeet_det->getTitle(); ?> 
        {
            title:'<?php echo $title; ?>',
            start:'<?php echo $edumeet_start ?>',
            end:'<?php echo $edumeet_end ?>',
            allDay: false
        },
    <?php endforeach; ?>
        ],

    eventColor: '#378006',    
});
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的日历功能,我需要获得用户选择的月份onchange.有没有人有这个问题的解决方案?

Mat*_* H. 31

也许我不完全理解你的问题,但听起来你只需要知道屏幕上的当前月份?

FullCalendar有一个"getDate"方法.

function getMonth(){
  var date = $("#calendar").fullCalendar('getDate');
  var month_int = date.getMonth();
  //you now have the visible month as an integer from 0-11
}
Run Code Online (Sandbox Code Playgroud)

对不起,如果这不是你问的问题.


小智 14

函数"getView"可能对您有用:

要获得日历月的第一天:

$(cal).fullCalendar('getView').start

要获取日历月的最后一天:

$(cal).fullCalendar('getView').end

获取日历的第一天:(上个月的最后几天)

$(cal).fullCalendar('getView').visStart

获取日历的最后一天:(下个月的前几天)

$(cal).fullCalendar('getView').visEnd

  • $(cal).fullCalendar('getView').开始给我第一个可见的日子. (2认同)
  • 小心,使用v3,它又改变了:https://fullcalendar.io/docs/views/View_Object/` $('#calendar').fullCalendar('getView').intervalStart`为日历月的第一天`$('#calendar').fullCalendar('getView').intervalndnd`表示当月最后一天之后的一天 (2认同)