Popover中的日期选择器不会显示

问题描述:

使用Twitter BootstrapBootstrap-datepicker扩展名。我无法在popover内使用日期选择器显示。Popover中的日期选择器不会显示

<a href="#" id="add-event-button" class="btn btn-small">Add an Event</a> 

$(document).ready(function() { 

    $("#add-event-button").popover({ 
     title: "Add an Event", 
     placement: 'bottom', 
     content: '<input class="datepicker" type="text" />', 
     html: true 
    }).click(function (e) { 
     e.preventDefault(); 
    }); 
}); 

的酥料饼显示得很好,并且<input class="datepicker" type="text" />外酥料饼的上下文的显示日期选择器细。有任何想法吗?

尝试与回调延长酥料饼的功能,因为日期选择器不能被添加到负载的不存在的元素,尝试这个办法:从这里回调扩展的解决方案:

var tmp = $.fn.popover.Constructor.prototype.show; 
$.fn.popover.Constructor.prototype.show = function() { 
    tmp.call(this); 
    if (this.options.callback) { 
    this.options.callback(); 
    } 
} 

$("#add-event-button").popover({ 
    title: "Add an Event", 
    placement: 'bottom', 
    content: '<input class="datepicker" type="text" />', 
    html: true, 
    callback: function() { 
    $('.datepicker').datepicker(); 
    } 
}).click(function (e) { 
    e.preventDefault(); 
}); 

编辑Callback function after tooltip/popover is created with twitter bootstrap?

+0

哇,完美无瑕的胜利!谢谢你的完美。 – mxmissile 2013-03-22 18:53:22

+3

您也可以只听“'shown.bs.popover''活动' – 2013-12-19 21:49:23

+1

感谢@naturalethic我还发现使用'inserted.bs.popover'事件效果更好,因为它与弹出窗口的定位效果相当。只要将popover模板添加到dom,就会调用它 – katwekibs 2016-07-30 10:43:15