Opened 12 years ago
Last modified 9 years ago
#6225 open bug
Datepicker: Inline datepicker and showCurrentAtPos
Reported by: | richelle | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | none |
Component: | ui.datepicker | Version: | 1.8.5 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Using an inline datepicker which displays several months and specifying showCurrentAtPos is not working correctly.
When you click on a date (doesn't matter which month) it moves all months back as many steps as you've specified for showCurrentAtPos.
Say, I have set numberOfMonths = 3 and showCurrentAtPos = 2, if I click any date the months displayed will move 2 months back (so if Aug, Sep, Oct are displayed, I click on any day, the months jump back so that now Jun, Jul, Aug are displayed). If showCurrentAtPos is set to 1, after clicking on a date, the calendars move back 1 month.
$('#dp').datepicker({numberOfMonths: 3, showCurrentAtPos: 2});
Change History (10)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
The fix from sergik above didn't work for me, as the _selectMonthYear method isn't fired when a date is selected (only from the dropdowns as far as I could tell). It appears that the calculation for moving the month location worked out every time the date is selected as well as when it's first drawn.
I've managed to get it working on mine by a quick (and probably dirty) fix, that passes a variable through to the _updateDatePicker, then _generateHTML methods so that it doesn't do the calculation on the clicking.
I would try and get this sorted cleanly, tested and forked on gitHub, but I'm a bit pressed for time, and this works for now. Hope it helps someone.
On line 892 change
this._updateDatepicker(inst);
to
this._updateDatepicker(inst, true);
Then on line 660 change
_updateDatepicker: function(inst) {
to
_updateDatepicker: function(inst, isClicked) {
Then on line 663 change
inst.dpDiv.empty().append(this._generateHTML(inst))
to
inst.dpDiv.empty().append(this._generateHTML(inst, isClicked))
Then on line 1353 change
_generateHTML: function(inst) {
to
_generateHTML: function(inst, isClicked) {
Then finally on line 1369 change
var drawMonth = inst.drawMonth - showCurrentAtPos;
to
var drawMonth = isClicked ? inst.drawMonth : (inst.drawMonth - showCurrentAtPos);
comment:4 Changed 10 years ago by
Milestone: | TBD → 1.11.0 |
---|
comment:5 Changed 10 years ago by
Status: | new → open |
---|
comment:7 Changed 10 years ago by
Summary: | Inline datepicker and showCurrentAtPos → Datepicker: Inline datepicker and showCurrentAtPos |
---|
Test case against master - http://jsfiddle.net/tj_vantoll/guxUw/.
comment:9 Changed 9 years ago by
Milestone: | 1.11.0 → none |
---|
comment:10 Changed 9 years ago by
You're basically saying that you want showCurrentAtPos
to be an init-only option and it shouldn't be considered after the datepicker has been rendered the first time. Is that what you're looking for?
I feel like there would need to be a different way to handle this than using showCurrentAtPos
.
Hi all. I've fixed this issue in my project.