jquery datepicker动态更改位置 [英] jquery datepicker change position dynamically

查看:632
本文介绍了jquery datepicker动态更改位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的页面上使用了几个日期提示,在某些情况下,我隐藏了一个div与其中一个。之后,其他日期检查员的位置不再正确,它们高于输入。我认为这是因为这个地方是初始化决定的,因为如果我再次显示该位置,那么这个位置是正确的。



但是如果一个其他datepicker(div)隐藏?

解决方案

也许在 beforeShow event:

  $(。is-datepicker)。datepicker(option,beforeShow输入,inst){
$(inst.dpDiv).position({
my:left top,
at:left bottom,
of:$(input )
});

position() http://api.jqueryui.com/position/



jsfiddle


I use several datepickers on my page and in some cases i hide a div with one of them. After that the position of the other datepickers is not correct anymore, they are way above the input. I think that is because the place is determined on initialisation, because if i show the div again the position is correct.

But how to make the position that it changes if an other datepicker (div) hides?

解决方案

Perhaps set the position in the beforeShow event:

$(".is-datepicker").datepicker("option", "beforeShow", function(input, inst){
   $(inst.dpDiv).position({
      my: "left top",
      at: "left bottom",
      of: $(input)
 });

position() was added in version 1.8 http://api.jqueryui.com/position/

jsfiddle

这篇关于jquery datepicker动态更改位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆