How the browser can remember the selected type of week, month, day

I use fullcalendar and set the title correctly: 'month, AgendaWeek, AgendaDay'

I did not set the default view. When I refresh the page every time the month view is displayed.

How can I select viewDay view and refresh the page, then the viewing agenda will remain?

Thanks.

+4
source share
3 answers

Get this plugin: https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js

Add to top of page:

<script type="text/javascript" src="jquery.cookie.js"></script> 

Then do it when you run fullcalendar (change the "month" to whatever you prefer by default)

 var calendarView = (!$.cookie('calendarDefaultView')) ? 'month' : $.cookie('calendarDefaultView'); $calendar.fullCalendar({ defaultView: calendarView, viewDisplay: function(view){ $.cookie('calendarDefaultView', view.name, {expires:7, path: '/'}); }, 
+5
source

One way is to use getView ( http://arshaw.com/fullcalendar/docs/views/getView/ ) on the page to unload and save it in the application session (possibly via ajax), and then use this session value to initialize the calendar when reloading the page. It is assumed that you have a webapp. If you need a clean client solution, try adding the selected view value to the query string on the next page, rather than in a session

+1
source

If I do not understand you correctly, do you want to set the defaultView parameter?

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

0
source

Source: https://habr.com/ru/post/1313733/


All Articles