【问题标题】:Fullcalendar, how to call month method?Fullcalendar,如何调用月份方法?
【发布时间】:2010-07-11 16:27:22
【问题描述】:

我正在使用全日历。

我想更改我的日历,所以默认月份是六月(加载的初始月份),我相信这就是我需要的: http://arshaw.com/fullcalendar/docs/current_date/month/

问题是,我不是很擅长.js……而且解释也不是很清楚。

这是我尝试过的:

<script type='text/javascript'> 

    $(document).ready(function() {

        var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();

        $('#calendar').fullCalendar('gotoMonth', 7);
        $('#calendar').fullCalendar({
            editable: true,
            events: [
                    {
                    imageAfterTime: $("<img src = 'images/flags/za.png' style='width:19px;height:13px'/>"),
                    imageAfterTitle: $("<img src = 'images/flags/mx.png' style='width:19px;height:13px'/>"),
                    title:' RSA-MEX ',
                    start:   '2010-06-11T14:30:00',
                    allDay: false,
                    },
>>>rest of events...

您可以在以下位置查看我的日历: http://cudamine.com/icame/sitemundial/calendar.html

谁能帮我调用这个月的方法?

【问题讨论】:

    标签: javascript jquery jquery-plugins fullcalendar


    【解决方案1】:

    “我想更改我的日历,所以默认月份是六月。”

    这个问题有点不清楚。根据日历初始化中的month: 5, 参数,您的日历从六月开始。

    但是上面的代码 sn-p 似乎正试图转到 8 月(第 7 个月)。那么真正想要的是什么?

    gotoMonth 似乎也已过时;它不在官方文档中(¿?)。

    您将使用 gotoDate 函数并将其放置在日历初始化之后。像这样:

    $(document).ready(function ()
    {
        var CurrentDate = new Date();
        var CurrentYear = CurrentDate.getFullYear();
    
        var MyCalendar  = $('#calendar');
        MyCalendar.fullCalendar(
        {
            defaultView: 'month',
            month: 5,
            editable: true,
            events: [
                    {
                        imageAfterTime: $("<img src = 'images/flags/za.png' style='width:19px;height:13px'/>"),
                        imageAfterTitle: $("<img src = 'images/flags/mx.png' style='width:19px;height:13px'/>"),
                        title: ' RSA-MEX ',
                        start: '2010-06-11T14:30:00',
                        allDay: false,
                    }
                    //... More events ... ...
                    ],
            timeFormat: 'H(:mm)',
            eventRender: function (event, eventElement)
            {
                if (event.imageAfterTime)
                    eventElement.find('span.fc-event-time').after($(event.imageAfterTime));
    
                if (event.imageAfterTitle)
                    eventElement.find('span.fc-event-title').after($(event.imageAfterTitle));
            }
        });
    
        //-- Advance to the calendar to August (month 7).
        MyCalendar.fullCalendar( 'gotoDate', CurrentYear, 7);
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-04
      • 2012-03-13
      • 2022-01-15
      • 1970-01-01
      相关资源
      最近更新 更多