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:
1 | var _gotoToday = jQuery.datepicker._gotoToday; |
2 | jQuery.datepicker._gotoToday = function (a){ |
3 | var target = jQuery(a); |
4 | var inst = this ._getInst(target[0]); |
5 | _gotoToday.call( this , a); |
6 | jQuery.datepicker._selectDate(a, jQuery.datepicker._formatDate(inst,inst.selectedDay, inst.selectedMonth, inst.selectedYear)); |
Tags: button, Datepicker, jQuery, jQuery UI, override, today
This entry was posted on June 14th, 2011
and is filed under jQuery.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response or Trackback from your own site.