parmarmayur9090 / jquery-datepicker

Automatically exported from code.google.com/p/jquery-datepicker
0 stars 0 forks source link

Cannot move focus to invisible control after selecting date #339

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Similar to issue 101 except I've been able to reproduce it using 
jQuery-datepicker.

What steps will reproduce the problem?

When attempting to use the "dateSelected" hook to set an INPUT of type "hidden" 
to the value selected from the calendar, IE 8 produces a JavaScript error.

Example code:

{{{
<html>
<head>
<script>
$("#date-pick").datePicker();
$("#date-pick").bind("dateSelected", function(e, selectedDate, td) {
    $("#date-display").html(selectedDate.asString());
    $(this).attr("value", selectedDate.asString());
});
</script>
</head>
<body>
<span id="date-display" />
<input id="date-pick" type="hidden" name="foo" />
</body>
</html>
}}}

What is the expected output? What do you see instead?

IE 8 produces this JavaScript error: Can't move focus to the control because it 
is invisible, not enabled, or of a type that does not accept the focus. This is 
a benign error as the INPUT still contains the selected date. Issue is that no 
further JavaScript will execute on the page.

What version of the datepicker are you using? On what operating system? And 
Which Browser?

$Id: jquery.datePicker.js 103 2010-09-22 08:54:28Z kelvin.luck $

Please provide any additional information below.

Issue stems from line 969

    c.ele.focus();

I believe a safe alternative would be to use exception handling

    try {
        c.ele.focus();
    } catch (e) {}

Original issue reported on code.google.com by cont...@andreinicholson.com on 24 Feb 2012 at 4:38