Skip to content

Instantly share code, notes, and snippets.

@jeffsheets
Created June 5, 2012 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jeffsheets/2876765 to your computer and use it in GitHub Desktop.
Save jeffsheets/2876765 to your computer and use it in GitHub Desktop.
jquery ui datepicker IE focus fix
/*
After jquery ui datepicker selection, blur and change
events fire before focus is returned to the input field,
handling a quirk from IE browsers
*/
$("input.dateInput").datepicker({
changeMonth: true,
changeYear: true,
showAnim: "fadeIn",
yearRange: 'c-30:c+30',
showButtonPanel: true,
/* fix buggy IE focus functionality */
fixFocusIE: false,
/* blur needed to correctly handle placeholder text */
onSelect: function(dateText, inst) {
this.fixFocusIE = true;
$(this).blur().change().focus();
},
onClose: function(dateText, inst) {
this.fixFocusIE = true;
this.focus();
},
beforeShow: function(input, inst) {
var result = $.browser.msie ? !this.fixFocusIE : true;
this.fixFocusIE = false;
return result;
}
});
@progmars
Copy link

There seems to be still one problem on IE with this: if you navigate with Tab through fields, then each second focus on datepicker field will not work. Tested on IE12.

@jeffsheets
Copy link
Author

@progmars interesting, thanks for the info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment