English 中文(简体)
如何选择一个月的时间,以填补一个完整的日历?
原标题:How to get selected month in jQuery full calendar?

We are using jQuery full calendar for displaying events from database.

I need to display the events below the calendar according to user selected month onchange. I can get data according to event date but I can t get user selected month in jQuery calendar.

$( #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 ,    
});

这是我使用的日历功能,我需要获得选定月份的用户<代码>onchange。 是否有办法解决这一问题?

最佳回答

Maybe I don t fully understand your quesiton, but it sounds like you just need to know the current month on screen?

“植被”方法。

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

如果是这样,你会问什么。

问题回答

The function "getView" which might be useful to you:

进入日历月的第一天:

$(cal).fullCalendar( getView ).start

To get the last day of calendar month:

<编码>$(cal).fullCalendar (edView >.end

进入日历的第一个可见日:(上个月的最后几天)

$(cal).fullCalendar (edView )visStart

进入日历的最后可见日:(下个月头几天)

<编码>$(cal).fullCalendar (edView >).visEnd

最后版本(2018年)需要使用这一法典!

jQuery("#your_selector").fullCalendar( getDate ).month()

www.un.org/Depts/DGACM/index_spanish.htm 正式日历-4

<script type="text/javascript">

document.addEventListener( DOMContentLoaded , function() {
    var calendarEl = document.getElementById( calendar );
    var calendar = new FullCalendar.Calendar(calendarEl, {
        ...
        ...
    });

    calendar.render();

    var cdate = calendar.getDate();
    var month_int = cdate.getMonth();
    alert((month_int+1));  // March 2020 month will return 3

});

</script>

这一解决办法对我有利。 很高兴帮助你。 感谢提出这一问题。

采用以下方式:<代码>,在您开始编制日历/代码时,可以做到:

 $( #calendar ).fullCalendar({

    dayClick: function(date, jsEvent, view) { 
        alert( Clicked on:   + date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear());  
    },

});

<> 正式日历 v2.6.1 (2016-02-17)

function getMonth() {
  var date = $("#calendar").fullCalendar( getDate );
  month = date._d.getMonth()+1
  console.log(month);
}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签