meow meow - 8 days ago 6
Javascript Question

how to make calendar not to redirect on current month

this is a

fullcalendar.js
script, I am using
fullCalendar.min.js
.

I have one problem, here I have used a username filter, and when I am on January and then select a name from the dropdown filter, then it automatically redirects me to the current month. Then every time I have to click the Previous arrow.

How to solve this problem if I am currently on July month and select a username, so that it selects the name but doesn't redirect to current month.

Please help.

Below is my script's code:

<script>

$(document).ready(function() {

$('#calendar').fullCalendar({
height: 350,
contentHeight: 300,
aspectRatio: 2,
eventLimit: 6,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay,listMonth'
},
defaultDate: '<?=date("Y-m-d")?>',
navLinks: false, // can click day/week names to navigate views
businessHours: false, // display business hours
editable: false,
eventLimit: true,
events: [ // my data coming here with foreach loop
,
start: '',
overlap: false,

color: ,



],

});

});

</script>


A little help will really be appreciated.

K48 K48
Answer

When you switch to another user, you should also remember the current month or time in some way. Depending on your page, it can be in a cookie, in a JS variable, window.storage etc.

Then you can switch to your previously selected date as follows:

//for testing; in real case you need to load this from somewhere
var previousDate = moment("2016-01"); 

$('#calendar').fullCalendar('gotoDate', previousDate);

You will place this at the end of your code that does the switching from one user or another, or in the viewRender.