Datepicker没有显示在框架上

时间:2013-08-15 23:44:25

标签: jquery css jquery-ui datepicker

我的frameset里面有frames,顶部的那个是打开一个日期选择器,但由于帧较低而没有完全显示...

我已尝试增加z-index的{​​{1}},但它无效。

我发布了一张图片,以便澄清对该问题的任何疑问:

enter image description here

如果无法做到这一点,我会接受新的解决方案(正在考虑打开一个对话框,但我认为这将是一团糟)。

提前致谢!

(我无法在jsFiddle上创建演示,因为显然没有在框架内显示框架集)

1 个答案:

答案 0 :(得分:3)

一个解决方案(黑客)是在显示日期选择器之后,您可以滚动到框架的底部以显示整个日期选择器。

示例:

$(".myDatepickers").datepicker({ 
    beforeShow: function(input, inst) {
        // There's no On-/After Show event for datepicker (closest is beforeShow), 
        // so use a timeout-hack to wait until the datepicker has rendered
        // and then scroll.
        setTimeout(function() {
            // Get the document height, but you could also get the position + size 
            // of the datepicker to scroll just so that the datepicker will show.
            var scrollTo = $(document).height();

            // And scroll to the new position.
            $("html, body").scrollTop(scrollTo);
        }, 500); // Increase/decrease the timeout as needed.
    } 
});

如果你在datepicker之后有内容,你可以获得datepicker的位置并偏移datepicker的大小以获得滚动位置。