最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Change defaultDate after Calendar is created (fullcalendar) - Stack Overflow

programmeradmin0浏览0评论

I´m integrating the JavaScript Calendar, called fullcalendar ( fullcalendar page) into my SAPUI5 Webpage. The calendar runs in a specific tab. I now want to change the default date after the calendar was created, to display a specific month.

setCalendar : function () {
    var that = this;
    if(!this.todayDate) {
        this.todayDate = new Date();
    }

    $("#EventBrowserDetail--calendarDiv").fullCalendar({
        header: {
            left: 'today',
            center: 'prev title next',
            right: 'month,basicWeek,basicDay'
        },
        defaultDate: that.todayDate,
        editable: false,
        eventLimit: true, // allow "more" link when too many events
        lazyFetching: false,
        eventClick: function(event, jsEvent, view){
            that.campaignSelectHandler(event.id, true, that);
        },
        eventMouseover: function(event, jsEvent, view)
        events: that.eventArray
    });
    [...]
},

I use this.todayDate to change the starting date before the function setCalendar() is called. It works fine for the first time, but if the calendar was already created once it remains with the last displayed month. For example: The month August is displayed, I switch to another tab and change the month to February. After that I rerender the events and call setCalendar() again, but it still remains at the month August.

Any idea and/or help?

Thanks in advance! :)

I´m integrating the JavaScript Calendar, called fullcalendar ( fullcalendar page) into my SAPUI5 Webpage. The calendar runs in a specific tab. I now want to change the default date after the calendar was created, to display a specific month.

setCalendar : function () {
    var that = this;
    if(!this.todayDate) {
        this.todayDate = new Date();
    }

    $("#EventBrowserDetail--calendarDiv").fullCalendar({
        header: {
            left: 'today',
            center: 'prev title next',
            right: 'month,basicWeek,basicDay'
        },
        defaultDate: that.todayDate,
        editable: false,
        eventLimit: true, // allow "more" link when too many events
        lazyFetching: false,
        eventClick: function(event, jsEvent, view){
            that.campaignSelectHandler(event.id, true, that);
        },
        eventMouseover: function(event, jsEvent, view)
        events: that.eventArray
    });
    [...]
},

I use this.todayDate to change the starting date before the function setCalendar() is called. It works fine for the first time, but if the calendar was already created once it remains with the last displayed month. For example: The month August is displayed, I switch to another tab and change the month to February. After that I rerender the events and call setCalendar() again, but it still remains at the month August.

Any idea and/or help?

Thanks in advance! :)

Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked May 4, 2015 at 15:09 Felix BockemuehlFelix Bockemuehl 1572 gold badges3 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Since the calendar instance already exist you can tell the plugin to go to a specific date using:

$('#EventBrowserDetail--calendarDiv').fullCalendar('gotoDate', that.todayDate);

Ref: http://fullcalendar.io/docs/current_date/gotoDate/

发布评论

评论列表(0)

  1. 暂无评论