FullCalendar "view" cacheable

I am wondering if there is an option missing from FullCalendar.

The default view is currently set to month. But I would like this to happen if the user views the week view, the next time the user visits the website, which will be displayed with the weekly view instead of the month. I am interested in setting this without using a database.

I know that jQuery UI tabs have this ability using the cache function ... is that what I can implement here? If so, how?

Any direction would be appreciated.

+4
source share
5 answers

changeView does not work because viewDisplay is called before it when setting up the calendar.

here is what works:

in the initializing object, add:

defaultView: $.cookie('fullcalendar_defaultView') || 'month', viewDisplay: function(view) { $.cookie('fullcalendar_defaultView', view.name); } 
+7
source

This setting can be saved in a cookie using jQuery.cookie , which is the library that the tabs use. How you deal with this and where it is configured is more a question that you need to answer, since you did not specify the code.

+2
source

You can use viewdisplay event

good cookie plugin http://plugins.jquery.com/project/Cookie

+2
source

In your case, you will need to put the code in the viewDisplay event. http://arshaw.com/fullcalendar/docs/display/viewDisplay/

Something like that.

 $('#calendar').fullCalendar({ viewDisplay: function(view) { setCookie("lastView", view.name); } }); 

You can get more information about what information is stored here view http://arshaw.com/fullcalendar/docs/views/View_Object/

Then , all you have to do is use changeView when the page is loaded using the method (for example, in ready jQuery or something else)

http://arshaw.com/fullcalendar/docs/views/changeView/

something like

 .fullCalendar( 'changeView', getCookie("lastView") ) 

There are many cookie plugins in jQuery, but they all work a little differently. I based my anser on some pure JS code found at http://jquery-howto.blogspot.com/2010/09/jquery-cookies-getsetdelete-plugin.html , somewhere there would be much better.

0
source

In version: 3.0.0, viewDisplay been renamed to viewRender , so the current code should be like:

defaultView: $.cookie('fullcalendar_defaultView') || 'month', viewRender: function(view) { $.cookie('fullcalendar_defaultView', view.name); }

0
source

All Articles