Skip to content

getDate null if you use only slider #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fabiopascolo opened this issue Oct 8, 2012 · 5 comments
Closed

getDate null if you use only slider #470

fabiopascolo opened this issue Oct 8, 2012 · 5 comments

Comments

@fabiopascolo
Copy link

If you set the time with the slider whitout selecting a date (today is selected by default) getDate return null.
For the same reason, even in the demo on the website restrict to start and end dates don't work well if you use only the slider. When you select the second input resets the first.

@xelagc
Copy link

xelagc commented Oct 25, 2012

I have the same problem!

@xelagc
Copy link

xelagc commented Oct 25, 2012

My workaround is adding this piece of code in _updateDateTime method:

            if(dp_inst.lastVal==""){
                dp_inst.currentYear=dp_inst.selectedYear;
                dp_inst.currentMonth=dp_inst.selectedMonth;
                dp_inst.currentDay=dp_inst.selectedDay;
            }

so, this method should be like this:

_updateDateTime: function(dp_inst) {
            dp_inst = this.inst || dp_inst;
            var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
                dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
                formatCfg = $.datepicker._getFormatConfig(dp_inst),
                timeAvailable = dt !== null && this.timeDefined;
            this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
            var formattedDateTime = this.formattedDate;

            // Workaround
            if(dp_inst.lastVal==""){
                dp_inst.currentYear=dp_inst.selectedYear;
                dp_inst.currentMonth=dp_inst.selectedMonth;
                dp_inst.currentDay=dp_inst.selectedDay;
            }

Maybe is not the best solution, but it seems to work fine ;-)

@sibartlett
Copy link

I had the same issue and the workaround above worked for me.

@zunou
Copy link

zunou commented Jan 29, 2013

same issue. same workaround

@trentrichardson
Copy link
Owner

Thanks for posting the fix, sorry it took so long. It is now in the dev branch for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants