【问题标题】:Bootstrap 3 popover with ui datepicker in - close on month click带有 ui datepicker 的 Bootstrap 3 弹出窗口 - 单击月份关闭
【发布时间】:2014-03-31 17:20:37
【问题描述】:

我在引导弹出窗口中有 UI 日期选择器日历 - 除了当我更改月份时弹出窗口关闭之外,所有工作都正常 - 只需要在“今天”按钮上或在正文点击之外关闭。

我找到了几个解决弹出框外部单击然后弹出框关闭的示例-但就我而言,我无法找到任何解决方案。

$('.popover-calendar').popover({
    html: true,
    placement: 'bottom',
    fixclass: 'calendar',
    content: function () {
        return $($(this).data('contentwrapper')).html();
    },
    callback: function () {
        $("#datepicker").datepicker({

        });
    }
}).on("click", function () {
    $(this).next().addClass('calendar-open');
});

$('body').on('click', function (e) {
    $('.popover-calendar').each(function () {
        if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
            $(this).popover('hide');
        }
    });

});

查看jsfiddle

如何产生问题 点击今天 - 然后点击下一个月或上个月的导航箭头 - 弹出框关闭(需要保留并显示更改的月份)。

【问题讨论】:

    标签: jquery twitter-bootstrap datepicker twitter-bootstrap-3 bootstrap-popover


    【解决方案1】:

    试试这个:JSFiddle

    现在您应该可以更改月份了,点击按钮,日期选择器就会关闭。

    我修改的代码:

    $('body').on('click', function (e) {
            $('.popover-calendar').each(function () {
                $('.popover-calendar').datepicker();
                $('.popover-calendar').mousedown(function() {
                    $(this).datepicker('hide');    
                });
            });
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-09
      • 2017-11-25
      • 1970-01-01
      • 2014-07-02
      相关资源
      最近更新 更多