Datepicker’s Today button problem

One of the features of jQuery UI Datepicker is an option (showButtonPanel) which will display two buttons: Today and Done. One would expect that upon clicking the Today button the today date will also be selected and used in input box. Instead, jQuery UI Datepicker simply selects it.

So to make jQuery UI Datepicker also use that date, you can override the _gotoToday function to also set the date to current datetime. I’ve put this into my jquery.ui.js file at the end, so it overrides this function immediately:

var _gotoToday = jQuery.datepicker._gotoToday;
jQuery.datepicker._gotoToday = function(a){
    var target = jQuery(a);
    var inst = this._getInst(target[0]);
    _gotoToday.call(this, a);
    jQuery.datepicker._selectDate(a, jQuery.datepicker._formatDate(inst,inst.selectedDay, inst.selectedMonth, inst.selectedYear));
}

Tags: , , , , ,

 
 
 
Content not available.
Please allow cookies by clicking Accept on the banner

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close