Skip to content

Instantly share code, notes, and snippets.

@seapy
Last active December 18, 2015 00:49
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 seapy/5699795 to your computer and use it in GitHub Desktop.
Save seapy/5699795 to your computer and use it in GitHub Desktop.
jQuery UI 에서 제공하는 DatePicker 를 사용할때 ie 10 미만 버전에서는 기본적으로는 잘 작동하지만 페이지가 스크롤되는경우 스크롤된 상태에서 DatePicker 를 표시할때 잘못된 위치가 나오는 경우가 있다. 이는 DatePicker 의 문제만은 아니고 jQuery UI 전체적인 문제인것 같다. 이게 일괄적으로 적용하면 ie10 에서 잘못된 위치에 나오기 때문에 브라우저 버전 체크가 필요하다.
_showDatepicker: function(input) {
input = input.target || input;
if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
input = $("input", input.parentNode)[0];
}
.......... 생략
if (!$.datepicker._pos) { // position below input
$.datepicker._pos = $.datepicker._findPos(input);
$.datepicker._pos[1] += input.offsetHeight; // add the height
// patch start
if (/msie [6-9]./.test(navigator.userAgent.toLowerCase())) {
// IE 6~9 버전에서 스크롤하는경우 위치값을 제대로 판단하지 못하는 오류 수정
// 브라우저 판단 참고 : http://stackoverflow.com/questions/14512826/impromptu-with-jquery-1-9-error-with-browser-msie
// jquery 캘린더 위치 오류 참고 : http://stackoverflow.com/questions/2834857/jquery-ui-datepicker-positioning-problem-when-scrolling-down-webpage
$.datepicker._pos[1] += document.body.scrollTop;
}
}
// patch end
isFixed = false;
$(input).parents().each(function() {
isFixed |= $(this).css("position") === "fixed";
return !isFixed;
});
.......... 생략
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment