themouette/jquery-week-calendar — Issue #89: firstDayOfWeek option not set on initial render
Author: robotdan
Created: 2011-10-24 17:02:27+00:00
State: open

I'm configuring this plugin with default settings so users don't need to specify them manually unless they wish to override.

For example, I have a map of options

options = {
"timeslotsPerHour": 4,
"timeslotHeight": 15,
"allowCalEventOverlap": false,
"defaultEventLength": 4,
"useShortDayNames": true,
"use24Hour": true,
"scrollToHourMillis": 500,
"buttons": false,
"businessHours": {start: 0, end:24}, // it's business time...
"timeFormat": "H:i",
"firstDayOfWeek": 1,
"daysToShow": 7,
"startOnFirstDayOfWeek": true,
"dateFormat": ""
};

A user then may initialize the calendar using these options.

calendar.weekCalendar( {
data: { 'events' : events,
'options' : options }

});

What is strange is that all of these options seem to work, except for 'firstDayOf Week'.
When I step through the jquery.weekcalendar.js code, it seems it does get set, but not in time for the first render.

If I call a refresh event after I initialize the calendar with my options and events, this option then is rendered properly.
Is this expected behavior?

The problem with me doing the refresh in order to get this option picked up - is that in Chrome it seems to cause a problem.
In Chrome, if I do this - I can create an event, but then if I try to move, resize, etc - I cannot. If I click anywhere else on the page, and then try again it works.
So in between event manipulation, if I click somewhere else I can then manipulate the event.

Perhaps this is just a Chrome issue, it seems to work just fine in IE 8.0.6, and Firefox 7.0.1.
Using Chrome 14.0.835.

Can anyone else confirm this issue, or provide some insight into why I have to refresh in order to get firstDayOfWeek option to be rendered?

Another way I've been able to work around, is to manuall return 1 from firstDayOfWeek function in the weekcalendar js.
I'd rather not change the source to work around this if possible.

example:

firstDayOfWeek: function(calendar) {
return 1; // *** workaround ***
if ($(calendar).weekCalendar('option', 'daysToShow') != 5) {
return 0;
} else {
//workweek
return 1;
}
}, // 0 = Sunday, 1 = Monday, 2 = Tuesday, ... , 6 = Saturday