Opened 10 years ago

Closed 10 years ago

#4513 closed bug (fixed)

datepicker doesn't set default date in dialog

Reported by: quasipickle Owned by:
Priority: major Milestone: 1.8
Component: ui.datepicker Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

Description

In IE 8 (at least - probably IE7 as well), when creating a datePicker with the dialog option, setting the second argument to a Date object does not set the default date of the datepicker. The default date must be set in the settings object with 'defaultDate'.

If 'defaultDate' is not set, but the second argument is set, the datepicker defaults to the current month.

Test page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type = "text/javascript" src = "http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type = "text/javascript" src = "ui.core.js"></script>
<script type = "text/javascript" src = "ui.datepicker.js"></script>
<script type = "text/javascript">
$(document).ready(function(){	
	var oDate = new Date();
	oDate.setYear(1990);

	$("#test").datepicker(
		'dialog',
		oDate,
		function(dateText,datePicker){
			$("#test").val(dateText);
		},
		{
			defaultDate:oDate
		}
	);
});
</script>
</head>
<body>
<input id = "test" type = "text" />
</body>
</html>

If you take out the last argument (the settings object), the datepicker will show a year of 2009. If the last argument is present, it will show a year of 1990.

Change History (3)

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

Milestone: TBD1.7.2

comment:2 Changed 10 years ago by Jörn Zaefferer

Milestone: 1.7.21.8

comment:3 Changed 10 years ago by kbwood

Resolution: fixed
Status: newclosed

Duplicate of #4514. Fixed in r2696.

Note: See TracTickets for help on using tickets.