SkyeBoniwell
SkyeBoniwell

Reputation: 7112

stay on current month

When I am in the month view of FullCalendar, then say I go back a few months to March and click on an event, then hit the browser 'back' button, how can I make it so that the browser knows to go back to March? Currently, it just goes back to the current month.

Thanks

Upvotes: 1

Views: 2402

Answers (1)

Adil Malik
Adil Malik

Reputation: 6357

Here is one possible solution:

From eventClick callback, when you redirect the user to the other page. Also send current day, month and year of the calendar in the URL. On that page get the values from URL and store them in session variables.

This is how you can get current date of the fullCalendar:

var calCurrDate = $('#calendar').fullCalendar('getView').start;
var date = calCurrDate.getDate();
var month = calCurrDate.getMonth();
var year = calCurrDate.getFullYear();

Now on calendar page check if those session variables are defined. If they are defined, add the following properties to fullCalendar

<cfif isDefined('SESSION.d')>
    <cfoutput>
        date: #SESSION.d#,
        month: #SESSION.m#,
        year: #SESSION.y#,
    </cfoutput>
</cfif>

For server side language I've used Coldfusion (as I know only this). You can easily understand the logic and translate it to your desired language.

Note: At the end of the calendar page you must destroy the session variables. Otherwise every time when you refresh the page you'll be taken to the same day, month and year.

I hope this helps. Thanks

Upvotes: 1

Related Questions