Skip to content

Instantly share code, notes, and snippets.

@imjp
Created January 12, 2012 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imjp/1603381 to your computer and use it in GitHub Desktop.
Save imjp/1603381 to your computer and use it in GitHub Desktop.
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
return this;
}
$('.ui-datepicker').datepicker({
onShow: function(picker, inst) {
//Code to show the datepicker in the center.
$('.ui-datepicker').center();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment