[FullCalendar 2] Landing on same view(month/week/day)

Forge Component
(31)
Published on 2019-03-29 by Daniel Filipe
31 votes
Published on 2019-03-29 by Daniel Filipe

Hi 

in traditional web, for fullcalendar2

when i performed some task(create a new event) in day view or week view the view is going to the month view. 

how can we achieve this by making the view to stay on week view or day view instead of going to the Month view.


Thanks

Srinivas Nalamati

Hello Srinivas,

To archive this you can use this piece of JavaScript:

$(document).on('click', '.fc-dayGridMonth-button, .fc-timeGridWeek-button, .fc-timeGridDay-button', function() {
    var CustomDefaultView = OSFullCalendarInstance.calendar.state.viewType;
    $('#"+InputDefaultView.Id+"').val(CustomDefaultView);
    $('#"+HiddenButton.Id+"').click();

});

This will basically assign and persist the default view into an input. Here you can assign it to a local variable. Getting this date on the local variable you can always know what's the "defaultView" where you're at. When you do some action you'll need to refresh the calendar with this default date you're storing. For that you'll just need to do this on the advanced config:

defaultView:'"+DefaultView+"',

Hope it helps! Regards,

Tiago Gomes


Tiago Gomes wrote:

Hello Srinivas,

To archive this you can use this piece of JavaScript:

$(document).on('click', '.fc-dayGridMonth-button, .fc-timeGridWeek-button, .fc-timeGridDay-button', function() {
    var CustomDefaultView = OSFullCalendarInstance.calendar.state.viewType;
    $('#"+InputDefaultView.Id+"').val(CustomDefaultView);
    $('#"+HiddenButton.Id+"').click();

});

This will basically assign and persist the default view into an input. Here you can assign it to a local variable. Getting this date on the local variable you can always know what's the "defaultView" where you're at. When you do some action you'll need to refresh the calendar with this default date you're storing. For that you'll just need to do this on the advanced config:

defaultView:'"+DefaultView+"',

Hope it helps! Regards,

Tiago Gomes


Thank you