Skip to main content

Search and Top Navigation

#4045 closed feature (wontfix)

Opened February 02, 2009 08:02PM UTC

Closed July 14, 2014 07:35PM UTC

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:
Description

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.

Cheers!

--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();
		}
		this._notifyChange(inst);
		this._adjustDate(target);
		//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));
	},
Attachments (0)
Change History (14)

Changed May 07, 2009 11:37AM UTC by jzaefferer comment:1

milestone: TBD1.next

Changed June 16, 2009 06:06PM UTC by imightbewrongbutidontthinkso comment:2

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.

Changed August 09, 2010 08:38AM UTC by Toverbal comment:3

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 1.next is long overdue since 1.6rc6 :)

Changed September 30, 2010 04:07PM UTC by pfurbacher comment:4

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.

http://www.apple.com/retail/menlopark/

Changed December 22, 2010 08:32PM UTC by wojciech comment:5

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

Changed January 06, 2011 01:44PM UTC by justcas comment:6

Replying to [comment:5 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.

Changed January 06, 2011 06:15PM UTC by danheberden comment:7

_comment0: 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) { _gotoToday.call( this, id ); }; \ }}} \ \ \ For an example of how to use the original bug report's request in use, see http://jsfiddle.net/danheberden/YgUg8/ \ \ \ \ 1294350458436126

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) { _gotoToday.call( this, id ); };

For an example of how to use the original bug report's request in use, see http://jsfiddle.net/danheberden/YgUg8/

Changed February 16, 2011 03:37PM UTC by romero83 comment:8

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.

Changed March 10, 2011 01:02PM UTC by scottgonzalez comment:9

#7093 is a duplicate of this ticket.

Changed June 26, 2012 01:22AM UTC by scottgonzalez comment:10

type: enhancementfeature

Changed October 03, 2012 04:54PM UTC by scottgonzalez comment:11

milestone: 1.next1.11.0

Changed October 19, 2012 10:19PM UTC by mikesherov comment:12

status: newopen

Changed June 24, 2014 11:51PM UTC by scottgonzalez comment:13

milestone: 1.11.0none

Changed July 14, 2014 07:35PM UTC by scottgonzalez comment:14

resolution: → wontfix
status: openclosed

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