How to keep user view choice in fullcalendar

Asked

Viewed 215 times

1

I have a system that uses the fullcalendar , depending on what the user is currently using it prefers a type of visualization, for example month, depending on what he is doing he prefers another type of visualization, week for example, and this he does by clicking the buttons that fullcalendar creates. What generates a lot of bother is that the user has to go through several calendars and always have to keep clicking on the buttons, there is some way to take this choice he made and leave as default for the next times he access the system. As soon as it accesses I already leave marked as default the week option, so I have something like this today:

$('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    defaultDate: '2015-12-23',
    defaultView: 'agendaWeek'
});

1 answer

2

Friend, you can do it in many ways.

To save the user preferences, I advise you to do via ajax, save to the database and load every time the user enters the system, however you can also do with localstorage and save the user’s preferences in the browser itself.

How would it look with localstorage:

You can create an object with user preferences, example:

//Setando preferencias
var prefRef = { 'id':321, 'tipo':'Mensal', 'cor':665533, 'itensPage':15};
localStorage.setItem('preferences', JSON.stringify(prefRef));

//Recuperando preferencias salva
var prefRef = json.parse(localStorage.getItem('preferences'));
alert('O usuario prefere a cor:' prefRef.cor );

Browser other questions tagged

You are not signed in. Login or sign up in order to post.