How Can I Select The List View To Match The Current View In Fullcalendar
My header right-hand buttons on Fullcalendar are 'month,agendaWeek,agendaDay,list) with the list defaulting to listWeek. How can I get the calendar to show the same timespan in the list view that the user was already viewing? In other words, if they are on the month view and click the list button, they should see the listMonth view; if they are on the agendaWeek view and they click the list button, they should see the listWeek view; and if they are on the agendaDay view and they click the list button, they should see the listDay view. Anybody know how to do this without having multiple "list" buttons?
I found a way to handle this. If anyone comes up with a better approach, please let me know. I use localStorage to keep the current view so the user can return to that view whenever they return to the calendar. This is updated whenever they change views.
In the customButtons section, I created my own button called listView, I set the list view based on the current view, and then call .fullCalendar( 'changeView', viewName )
listView: {
text: 'list',
click: function() {
var currentView = localStorage.getItem("AI_Default_FullCalendar_View");
if(currentView.indexOf('list') == -1){
if(currentView.indexOf('month') != -1){
currentView = 'listMonth';
}
if(currentView.indexOf('Week') != -1){
currentView = 'listWeek';
}
if(currentView.indexOf('Day') != -1){
currentView = 'listDay';
}
}
localStorage.setItem('AI_Default_FullCalendar_View', currentView);
$("#calendar").fullCalendar('changeView', currentView);
}
}
链接地址: http://www.djcxy.com/p/81228.html