Opened 16 years ago

Closed 15 years ago

Last modified 14 years ago

#1996 closed bug (fixed)

datepicker - next/prev with multiple months and min/max

Reported by: emielroelofsen Owned by: kbwood
Priority: major Milestone: 1.5
Component: ui.core Version: 1.2.1
Keywords: datepicker Cc: [email protected]
Blocked by: Blocking:

Description

The function _canAdjustMonth is't correct.

Example

I want to show 3 months ( numberOfMonths: 3 )
My minimum date is 2008-01-26 ( minDate: new Date(2008, 1 - 1, 26) )
My maximum date is 2008-04-27 ( minDate: new Date(2008, 4 - 1, 27) )
hideIfNoPrevNext is set to true

Because of the bug in the function _canAdjustMonth I can press the next button until juni 2008. The solution is also to calculate the numberOfMonths.

Solution

OLD FUNCTOIN

_canAdjustMonth: function(offset) {            
   var date = new Date(this._selectedYear, this._selectedMonth + offset, 1);
   if (offset < 0) {
      date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
   }
   return this._isInRange(date);
},

NEW FUNCTION

_canAdjustMonth: function(offset) {            
   var month = offset > 0 ? 
      this._selectedMonth + offset + this._get('numberOfMonths') - 1 :
      this._selectedMonth + offset;
   var date = new Date(this._selectedYear, month, 1);
   if (offset < 0) {
      date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
   }
   return this._isInRange(date);
},

Emiel Roelofsen

Change History (5)

comment:1 Changed 15 years ago by kbwood

Owner: set to kbwood
Status: newassigned

comment:2 Changed 15 years ago by kbwood

Summary: ui.datepicker.jsdatepicker - next/prev with multiple months and min/max

comment:3 Changed 15 years ago by kbwood

Resolution: fixed
Status: assignedclosed

Implemented a fix that prevents non-selectable months at the end of a multiple month display (unless also constrained by the minDate).

comment:4 Changed 15 years ago by (none)

Milestone: 1.2.2

Milestone 1.2.2 deleted

comment:5 Changed 14 years ago by paul

Milestone: 1.5
Note: See TracTickets for help on using tickets.