jQuery UI datepicker positioning issue in scrollable div -


my page contains form inside scrollable div. in form there few datepickers. if scroll while datepickers open, not scroll content of div.

i've found hundred posts same issues online, none of solutions work in environment.

this jsfiddle demostrates problem: problem

and jsfiddle demostrates fix: fix

$("input").datepicker({  beforeshow: function(input, obj) {     $(input).after($(input).datepicker('widget')); } }); 

the fix done in jquery v1.7.2, i'm using v1.10.2 jquery ui v1.10.3. if switch jquery library version v1.10.2 in fix jsfiddle, datepicker breaks.

is there working fix latest jquery library? (if of consequence, i'm using mvc4 ef4.5)

while question old, i'll share recent solution:

the problem exists because #ui-datepicker-div created jquery ui added absolutely positioned element near end of dom. attempting change position in beforerender gets overridden jquery ui. known issue: see https://bugs.jqueryui.com/ticket/8223

to solve problem (tested in jquery ui 1.11.4) can add .bind() event end of datepicker instantiation:

$("first-selector").datepicker().bind('click',function () {   $("#ui-datepicker-div").appendto("other-selector"); }); 

for example, "other-selector" parent of element datepicker attached: $(this).closest('the-datepicker-element-parent'). moves single #ui-datepicker-div box (which jquery ui places @ end of dom) new location can better control positioning.

specifically, "other-selector" should position: relative; making absolutely positioned #ui-datepicker-div relative new parent. once so, scrolls fine.

this solution allows datepicker work correctly on mobile devices , tablets can otherwise difficult use if picker rendered partially off-screen.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -