How can the browser remember the selected view of week, month ,day
I use fullcalendar and set header right: 'month,agendaWeek,agendaDay'
I did not set the default view. When I refresh the page everytime the month view display.
How开发者_如何学C can I select the agendaDay view and refresh the page then the agendaDay view remains?
Thanks.
Get this plugin: https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js
Add to the top of your page:
<script type="text/javascript" src="jquery.cookie.js"></script>
Then do this when you intialize fullcalendar (change 'month' to whatever you prefer as default)
var calendarView = (!$.cookie('calendarDefaultView')) ? 'month' : $.cookie('calendarDefaultView');
$calendar.fullCalendar({
defaultView: calendarView,
viewDisplay: function(view){
$.cookie('calendarDefaultView', view.name, {expires:7, path: '/'});
},
One technique is to use the getView (http://arshaw.com/fullcalendar/docs/views/getView/) on page unload and save it in the app session (via ajax maybe). And then use this session value to initialize the calendar when the page reloads. This is assuming you have an webapp. If you need a pure client-side solution, try appending the selected view value to the query string of the next page, instead of session
Unless I'm not understanding you correctly surely you want to set the defaultView
option?
http://arshaw.com/fullcalendar/docs/views/defaultView/
精彩评论