Now select the current month if exists.

This commit is contained in:
Alexis Lahouze
2013-01-26 12:47:04 +01:00
parent a7c63c270e
commit 8062cb4c59
2 changed files with 17 additions and 9 deletions

View File

@ -285,15 +285,23 @@ var ListViewModel = function() {
var monthToSelect = null;
// Reset selected month to the new instance corresponding to the old one
if(self.month()) {
// Find the new instance of the previously selected month.
$.each(self.months(), function(index, month) {
var today = new Date();
var currentYear = today.getFullYear().toString();
var currentMonth = (today.getMonth() + 1 < 10 ? "0" : "") + (today.getMonth() + 1);
// Find the new instance of the previously selected month.
$.each(self.months(), function(index, month) {
// Reset selected month to the new instance corresponding to the old one
if(self.month()) {
if(month.year() === self.month().year() && month.month() === self.month().month()) {
monthToSelect = month;
}
});
}
} else {
if(month.year() === currentYear && month.month() === currentMonth) {
monthToSelect = month;
}
}
});
// Set selected month to the last one if not yet selected.
if(!monthToSelect && self.months().length > 0) {