Skip to main content

Search and Top Navigation

#6694 closed bug (fixed)

Opened November 24, 2010 11:43PM UTC

Closed February 03, 2011 01:53PM UTC

Last modified February 03, 2011 01:54PM UTC

datepicker does not fire change event in IE8

Reported by: cmcnulty Owned by:
Priority: minor Milestone: 1.8.10
Component: ui.datepicker Version: 1.8.6
Keywords: Cc:
Blocked by: Blocking:
Description

When using IE8 and entering a date using the keyboard the change event isn't raised when the input loses focus if the datepicker was visible whilst entering the date.

Steps to reproduce:

1. Use IE 8

2. Focus the input field (datepicker should show).

3. Enter the date "10/10/2010" in to the first input field (do not close the datepicker).

4. Tab to the next input field.

Result: The page still shows "Date: none"

Expected Result: The page should show "Date: 10/10/2010"

http://www.jsfiddle.net/gUc5c/8/

Notes: The field we are interested in is "Date:", "Other:" is just for verification that change and tabbing is working correctly.

The error seems to be coming from the focus changing during typing in the date box whilst the picker is visible. This happens when the user starts entering the year part of the date.

Stack trace when "_change_data" is changed due to focus event.

   1. jQuery.js:1174 (data == '10/10/2')
   2. jQuery.js:2636 (beforeactivate)
   3. jQuery.js:2260 (event.type == 'focus')
   4. ...
   5. jQuery-ui.js:7768 (_updateDatepicker, inst.input.focus())
   6. jQuery-ui.js:7651 (_doKeyUp)

Html:

   1. <div>
   2.     <input id="a1" type="text">
   3.     Date: <span id="a2">none</span>
   4. </div>
   5.

   6. <div>
   7.     <input id="b1" type="text">
   8.      Other: <span id="b2">none</span>
   9. </div>

Javascript:

   1. $(function () {  
   2.     $('#a1').datepicker ({
   3.         showOn: 'focus',
   4.         buttonText: 'clickme'
   5.     }).change (function () {
   6.         $('#a2').text ($(this).val ());
   7.     })
   8.     
   9.     $('#b1').change (function () {
  10.         $('#b2').text ($(this).val ());
  11.     })
  12. });

The problem also appears in 1.4.3 with jQuery UI 1.8.5: http://www.jsfiddle.net/gUc5c/13/ Problem does not occur in 1.4.2 with jUI 1.8.4 http://www.jsfiddle.net/gUc5c/14/

text of bug report copied from:

http://forum.jquery.com/topic/change-event-not-raised-when-using-datepicker-in-ie8

My sincere apologies for the copy/paste. I couldn't have written the bug report better.

Attachments (0)
Change History (5)

Changed December 31, 2010 04:42PM UTC by tobias.brunner comment:1

Changed February 03, 2011 01:40PM UTC by scottgonzalez comment:2

Filed a bug with jQuery core: http://bugs.jquery.com/ticket/8157

Changed February 03, 2011 01:53PM UTC by Tobias Brunner comment:3

resolution: → fixed
status: newclosed

Datepicker: only set the focus explicitly if it is not already on the target field. Fixed #6694 – datepicker does not fire change event in IE8

jQuery stores the current content of a field whenever it gets the focus. Since the fixed function is also called for KeyUp events the change event is not triggered anymore when the input looses focus.

(cherry picked from commit 39cf7d5bb4f9dfe1ada5dc2499f5c91e536ec96b)

Changeset: d14366abcea59b4fb6d0fb1ce48a6ad196ddff3a

Changed February 03, 2011 01:53PM UTC by Tobias Brunner comment:4

Datepicker: only set the focus explicitly if it is not already on the target field. Fixed #6694 – datepicker does not fire change event in IE8

jQuery stores the current content of a field whenever it gets the focus. Since the fixed function is also called for KeyUp events the change event is not triggered anymore when the input looses focus.

Changeset: 39cf7d5bb4f9dfe1ada5dc2499f5c91e536ec96b

Changed February 03, 2011 01:54PM UTC by scottgonzalez comment:5

milestone: 1.91.8.10