这是我正在处理的代码
swal({
title: "Confirm details?",
text:'<input id="datetimepicker" class="form-control" autofocus>',
type: "warning",
customClass: 'swal-custom-width',
html:true,
showCancelButton: true,
confirmButtonClass: "btn-success",
confirmButtonText: "Confirm",
cancelButtonText: "Cancel",
closeOnConfirm: false,
closeOnCancel: false,
showLoaderOnConfirm: true
},
我想在甜蜜警报内的输入中设置日期时间选择器。
$('#datetimepicker').datetimepicker({
format: 'DD/MM/YYYY hh:mm A',
defaultDate: new Date()
});
当我点击甜蜜警报时,输入字段无法点击或对其执行任何操作。日期也没有出现。任何人都可以告诉我什么是错的?感谢。
单击输入选择日期时出现控制台错误
Uncaught RangeError: Maximum call stack size exceeded.
at HTMLDivElement.trigger (jquery-2.2.3.min.js:3)
at Object.trigger (jquery-2.2.3.min.js:4)
at HTMLDivElement.<anonymous> (jquery-2.2.3.min.js:4)
at Function.each (jquery-2.2.3.min.js:2)
at n.fn.init.each (jquery-2.2.3.min.js:2)
at n.fn.init.trigger (jquery-2.2.3.min.js:4)
at c.<anonymous> (bootstrap.min.js:6)
at HTMLDocument.f (jquery-2.2.3.min.js:2)
at HTMLDocument.dispatch (jquery-2.2.3.min.js:3)
at HTMLDocument.r.handle (jquery-2.2.3.min.js:3)
答案 0 :(得分:2)
使用 onOpen listerner触发datetimepicker
onOpen: function() {
$('#datetimepicker').datetimepicker({
format: 'DD/MM/YYYY hh:mm A',
defaultDate: new Date()
});
},
在你的情况下是这样的:
swal({
title: "Confirm details?",
html:'<input id="datetimepicker" class="form-control" autofocus>',
type: "warning",
onOpen: function() {
$('#datetimepicker').datetimepicker({
format: 'DD/MM/YYYY hh:mm A',
defaultDate: new Date()
});
}
}