Jquery Popover中的日期选择器赢得';t显示
使用和扩展。我无法在一个窗口中显示日期选择器Jquery Popover中的日期选择器赢得';t显示,jquery,twitter-bootstrap,datepicker,Jquery,Twitter Bootstrap,Datepicker,使用和扩展。我无法在一个窗口中显示日期选择器 $(文档).ready(函数(){ $(“#添加事件按钮”).popover({ 标题:“添加事件”, 位置:'底部', 内容:“”, html:对 })。单击(功能(e){ e、 预防默认值(); }); }); popover显示得很好,popover上下文之外的显示日期选择器很好。有什么想法吗?尝试使用回调扩展popover函数,因为无法在加载时将datepicker添加到不存在的元素,请尝试以下操作: var tmp = $.fn.p
$(文档).ready(函数(){
$(“#添加事件按钮”).popover({
标题:“添加事件”,
位置:'底部',
内容:“”,
html:对
})。单击(功能(e){
e、 预防默认值();
});
});
popover显示得很好,popover上下文之外的
显示日期选择器很好。有什么想法吗?尝试使用回调扩展popover函数,因为无法在加载时将datepicker添加到不存在的元素,请尝试以下操作:
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();
});
var tmp=$.fn.popover.Constructor.prototype.show;
$.fn.popover.Constructor.prototype.show=函数(){
tmp.呼叫(本);
if(this.options.callback){
this.options.callback();
}
}
$(“#添加事件按钮”).popover({
标题:“添加事件”,
位置:'底部',
内容:“”,
是的,
回调:函数(){
$('.datepicker').datepicker();
}
})。单击(功能(e){
e、 预防默认值();
});
编辑:这里的回调扩展解决方案:感谢@naturalethic,我还发现使用“inserted.bs.popover”事件效果更好,因为它可以很好地定位popover。一旦popover模板添加到dom中,就会调用它
$(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();
});
});
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();
});