[英]Datepicker inside modal dialog not working
This question was asked many times and had different answers, i tried all solution suggested (using the z-index property ...) but still not working. 这个问题被问了很多遍,答案也不同,我尝试了所有建议的解决方案(使用z-index属性...),但仍然无法正常工作。 In a page (not a popup) the code works fine.
在页面(不是弹出窗口)中,代码可以正常工作。 This is my code :
这是我的代码:
Modal popup : 模式弹出窗口:
<button class="btn btn-azure" id="bootbox-operation">Add operation</button>
<div id="newOperationModal" style="display: none;">
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="form-group">
<div class="input-group">
<input class="form-control datepicker" type="text" data-date-format="dd-mm-yyyy">
<span class="input-group-addon">
<i class="fa fa-calendar"></i>
</span>
</div>
</div>
</div>
Jquery script: jQuery脚本:
$(function () {
$("#bootbox-operation").on('click',
function () {
bootbox.dialog({
message: $("#newOperationModal").html(),
title: "Nouvelle opération : Chargement",
className: "modal-success",
buttons: {
success: {
label: "Enregistrer",
className: "btn-blue",
callback: function () { }
},
"Annuler": {
className: "btn-default",
callback: function () { }
}
}
});
$(function () {
console.log("test");
$(".datepicker").datepicker();
});
});
});
//--Bootstrap Date Picker--
//$(function () { // will trigger when the document is ready
// $(".datepicker").datepicker();
//});
because you are calling the date picker outside...call it on modal completion call back ie .on('shown.bs.modal'
因为您正在外面调用日期选择器...在模式完成时调用它,即
.on('shown.bs.modal'
$(function () {
var box= bootbox.dialog({
message: $("#newOperationModal").html(),
title: "Nouvelle opération : Chargement",
className: "modal-success",
buttons: {
success: {
label: "Enregistrer",
className: "btn-blue",
callback: function () { }
},
"Annuler": {
className: "btn-default",
callback: function () { }
}
}
});
box.on("shown.bs.modal", function() {
$(".datepicker").datepicker();
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.