【问题标题】:Bootstrap datepicker inside modal scrolling with parent page, not with modalBootstrap datepicker 在模态滚动中使用父页面,而不是模态
【发布时间】:2017-07-05 05:28:28
【问题描述】:

我有一个引导模板,我必须在模式中使用 datepicker。 modal 的内容是可滚动的。当我单击日期选择器字段并滚动页面时,日期选择器会随父页面引用一起滚动,而模式内容根本不会滚动。此外,当模式滚动时,日期选择器停留在“固定”位置(因为父页面不滚动)。关于如何将模态弹出窗口作为引导程序中日期选择器的父引用的任何想法?

【问题讨论】:

    标签: twitter-bootstrap css bootstrap-modal bootstrap-datepicker


    【解决方案1】:

    问题开始是因为引导程序会自动将小部件附加到“body”(默认容器)中,这就是为什么如果您使用模态框,您必须指定容器。如果您使用的是引导模式,那么您可以使用“容器:'.modal-body'”。

    $('#myInput').datepicker({ 容器:'.modal-body' });

    希望对你有帮助!

    【讨论】:

    • 谢谢!在找到这个之前,我尝试了各种 Heath Robinson 解决方案——没有一个有效。我在 Vue 项目中使用 Bootstrap 日期选择器作为包装组件,这个修复效果很好。
    【解决方案2】:

    使用 datepicker('place') 选项:

    $( "#model" ).scroll(function() {
        $('.datepicker').datepicker('place');
    }); 
    

    【讨论】:

    • 那个参数'place'是什么意思?
    猜你喜欢
    • 1970-01-01
    • 2016-07-24
    • 2018-05-21
    • 1970-01-01
    • 2018-07-23
    • 2013-12-27
    • 1970-01-01
    • 2016-12-12
    • 2020-01-25
    相关资源
    最近更新 更多