Opened 14 years ago

Closed 9 years ago

#4045 closed feature (wontfix)

Datepicker -- Today button enhancement

Reported by: aguita Owned by:
Priority: minor Milestone: none
Component: ui.datepicker Version: 1.6rc6
Keywords: today Cc:
Blocked by: Blocking:


I'm new to JQuery UI, and I love it. When applying the Datepicker class to my application here at work, I noticed that the Today button simply highlights today's date. The user then would need to click on that date to return the value to the input field. However, I feel that if the user clicks on today's date, most likely that is the date that they want to put into the input field. Therefore, I added that functionality.

I'm not sure if others would need or want this functionality, but I edited my personal version of the jquery.ui.all.js file to include this. I'm giving the code here to the user group in case others would like this functionality.


--Ryan Waterer

/* Action for current link. */
	_gotoToday: function(id) {
		var target = $(id);
		var inst = this._getInst(target[0]);
		if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
			inst.selectedDay = inst.currentDay;
			inst.drawMonth = inst.selectedMonth = inst.currentMonth;
			inst.drawYear = inst.selectedYear = inst.currentYear;
		else {
		var date = new Date();
		inst.selectedDay = date.getDate();
		inst.drawMonth = inst.selectedMonth = date.getMonth();
		inst.drawYear = inst.selectedYear = date.getFullYear();
		//Added by Ryan Waterer on 1/30/2009 to have it return the value 
                //when the person selects the "Today" button
		this._selectDate(id, this._formatDate(inst,
			inst.selectedDay, inst.drawMonth, inst.drawYear));

Change History (14)

comment:1 Changed 14 years ago by Jörn Zaefferer


comment:2 Changed 14 years ago by imightbewrongbutidontthinkso

This doesn't seem to work in IE7. After you click the Today button, the current date momentarily fills the datepicker text field, but then is immediately removed by the datepicker text field focus.

It does work in Firefox 3.0.10.

comment:3 Changed 13 years ago by Toverbal

I have tried to apply this fix and it seems to work perfectly in IE7, IE8 and IE8 compatibility mode. Also I personally think clicking Today should select today's date instead of displaying the current month. Is there a chance this change will be made, since it has been 18 months ago and is long overdue since 1.6rc6 :)

comment:4 Changed 12 years ago by pfurbacher

We have gotten feedback from users who are confused as to why "Today" does not select today. I think users expect to select when pressing "Today" because they take the button's label at face value and have experience with other calendars which behave as advertised.

I just did a survey of some other calendars, and "Today" buttons do indeed seem to select today, in addition to snapping back to the current month. As an example, see Apple's pop up calendar on their retail store pages, just above the workshop and event description.

comment:5 Changed 12 years ago by wojciech

We replaced Prototype based date selector with jQuery UI datepicker. Works great, but new behavior of "Today" button is not acceptable.

comment:6 in reply to:  5 Changed 12 years ago by justcas

Replying to wojciech:

We replaced Prototype based date selector with jQuery UI datepicker. Works great, but new behavior of "Today" button is not acceptable.

Sorry, did you say, not acceptable? Do you determine that from your userbase, or your own experience? In my view, users have already shown you why they expect such behaviour (not to mention companies much larger then yours), and why the current situation is not sufficiënt.

Your opinion is therefore less relevant, a user interface that follows accepted standards will always be of more importance then the silly personal issues you might have with it.

comment:7 Changed 12 years ago by danheberden

Regardless of how anyone thinks this particular feature should work, I think the obvious solution of writing the function to work the way you need it to is being overlooked.

In the case of the original ticket, outside of jQuery-ui's source one can override the function on the objects prototype.

If the UI widget is using the factory, it would be like

$.ui.accordion.prototype._whateverFunctionToOverride = function() { /* stuff */ };

but in the case of date picker, while the same principle applies, it's not using the widget factory so it's on the jquery object itself

var _gotoToday = $.datepicker._gotoToday;
$.datepicker._gotoToday = function(id) { this, id ); };

For an example of how to use the original bug report's request in use, see

Last edited 12 years ago by danheberden (previous) (diff)

comment:8 Changed 12 years ago by romero83

I really do not understand why the datepicker developers cannot invent a new option for to choose today's button behaviour. Our customers prefer the "select today date and hide datepicker" method. But ok, I always have to hack the js after version change. Anyway, I like JQuery UI.

comment:9 Changed 12 years ago by Scott González

#7093 is a duplicate of this ticket.

comment:10 Changed 11 years ago by Scott González

Type: enhancementfeature

comment:11 Changed 10 years ago by Scott González

Milestone: 1.next1.11.0

comment:12 Changed 10 years ago by mikesherov

Status: newopen

comment:13 Changed 9 years ago by Scott González

Milestone: 1.11.0none

comment:14 Changed 9 years ago by Scott González

Resolution: wontfix
Status: openclosed

The today button won't exist in the rewrite, instead users will be able to fully customize what buttons exist.

Note: See TracTickets for help on using tickets.