Skip to content

Instantly share code, notes, and snippets.

@stalniy
Forked from jeffsheets/datepicker-focus.js
Created June 18, 2014 12:51
Show Gist options
  • Save stalniy/129a8859bf98cfc5d33e to your computer and use it in GitHub Desktop.
Save stalniy/129a8859bf98cfc5d33e to your computer and use it in GitHub Desktop.
/*
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;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment