Return 日期来自 bootstrap material 日期选择器
Return date from bootstrap material date picker
抱歉,如果这可能是一个愚蠢的问题,但我如何return 用户从 Bootstrap material 日期选择器中选择日期?
我正在将它与 sweetalert2 结合使用,我需要 return 有人选择它后的日期。
swal.setDefaults({
confirmButtonText: 'Next →',
showCancelButton: true,
animation: false,
progressSteps: ['1', '2', '3']
})
var steps = [{
title: 'Title',
input: 'text',
text: 'Please specify reminder title'
},
{
title: 'Notes',
input: 'textarea',
text: 'Please leave yourself some notes for this reminder'
},
{
title: 'Time',
html: '<input type="text" id="date-format" class="form-control" placeholder="Saturday 24 June 2017 - 21:44">',
text: 'Please leave yourself some notes for this reminder',
onOpen: function() {
$('#date-format').bootstrapMaterialDatePicker({
format: 'dddd DD MMMM YYYY - HH:mm'
});
},
preConfirm: function() {
return Promise.resolve($('.input-daterange-timepicker').val());
}
}
]
swal.queue(steps).then(function(result) {
swal.resetDefaults()
console.log(result);
swal({
title: 'All done!',
confirmButtonText: 'Lovely!'
})
}, function() {
interval = setInterval(reminderTimes, 10000)
swal.resetDefaults();
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css" />
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.7.0/sweetalert2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@6.7.0/dist/sweetalert2.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-datetimepicker/2.7.1/js/bootstrap-material-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-datetimepicker/2.7.1/css/bootstrap-material-datetimepicker.min.css" />
目前正在return为步骤1和2输入正确的信息,但日期步骤只是returns true
,如下图
["title", "notes", true]
我需要它 return 用户选择的日期
尝试像这样更改您的解析行:
return Promise.resolve($('#date-format').bootstrapMaterialDatePicker().val());
抱歉,如果这可能是一个愚蠢的问题,但我如何return 用户从 Bootstrap material 日期选择器中选择日期?
我正在将它与 sweetalert2 结合使用,我需要 return 有人选择它后的日期。
swal.setDefaults({
confirmButtonText: 'Next →',
showCancelButton: true,
animation: false,
progressSteps: ['1', '2', '3']
})
var steps = [{
title: 'Title',
input: 'text',
text: 'Please specify reminder title'
},
{
title: 'Notes',
input: 'textarea',
text: 'Please leave yourself some notes for this reminder'
},
{
title: 'Time',
html: '<input type="text" id="date-format" class="form-control" placeholder="Saturday 24 June 2017 - 21:44">',
text: 'Please leave yourself some notes for this reminder',
onOpen: function() {
$('#date-format').bootstrapMaterialDatePicker({
format: 'dddd DD MMMM YYYY - HH:mm'
});
},
preConfirm: function() {
return Promise.resolve($('.input-daterange-timepicker').val());
}
}
]
swal.queue(steps).then(function(result) {
swal.resetDefaults()
console.log(result);
swal({
title: 'All done!',
confirmButtonText: 'Lovely!'
})
}, function() {
interval = setInterval(reminderTimes, 10000)
swal.resetDefaults();
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css" />
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.7.0/sweetalert2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@6.7.0/dist/sweetalert2.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-datetimepicker/2.7.1/js/bootstrap-material-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-datetimepicker/2.7.1/css/bootstrap-material-datetimepicker.min.css" />
目前正在return为步骤1和2输入正确的信息,但日期步骤只是returns true
,如下图
["title", "notes", true]
我需要它 return 用户选择的日期
尝试像这样更改您的解析行:
return Promise.resolve($('#date-format').bootstrapMaterialDatePicker().val());