此解决方法为我做了。任何更好的接近这个问题是值得欢迎的。
function BootboxContent() {
var frm_str = '<form id="some-form">'
+ '<div class="form-group">'
+ '<label for="date">Date</label>'
+ '<input id="date" class="date span2 form-control input-sm" size="16" placeholder="dd-mm-yy" type="text">'
+ '</div>'
+ '</form>';
var object = $('<div/>').html(frm_str).contents();
object.find('.date').datepicker({
format: 'yyyy-mm-dd',
autoclose: true
}).on('changeDate', function (ev) {
$(this).blur();
$(this).datepicker('hide');
});
return object
}
//Show the datepicker in the bootbox
bootbox.dialog({
message: BootboxContent,
title: "Reschedule Rule",
buttons: {
main: {
label: "OK",
className: "btn-primary"
}
}
});
datepicker将显示在模态叠加层后面。在datepicker.css,添加的z-index:99999重要到.datepicker
要ajust权下根据您的bootbox对话框中的位置的日期选择器输入压延,增加以下样式:
.modal-open .datepicker {
left: 52% !important; //Change it according to the position of your dialog
top: 25% !important; //Change it according to the position of your dialog
}