admin管理员组文章数量:1356595
Hi I'm trying to replace the datetimepicker with flatpickr but I can't handle this situation. Not wishing to use the Range plugin of flatpickr I would like to be able to change the minDate or maxDate of an instance using the onChange event. Unfortunately I found little information about this passage on the guides
flatpickr('#start_time', {
locale: 'it',
enableTime: true,
plugins: [
new confirmDate({
confirmIcon: "<i class='fa fa-check'></i>",
confirmText: '',
showAlways: true,
}),
],
showAlways: false,
theme: 'airbnb',
time_24hr: true,
altInput: true,
altFormat: 'F j, Y H:i',
dateFormat: 'Z',
weekNumbers: true,
maxDate: $('#end_time').attr('value'),
onClose: function(selectedDates, dateStr, instance) {
// Change #end_time minDate
},
});
flatpickr('#end_time', {
locale: 'it',
enableTime: true,
plugins: [
new confirmDate({
confirmIcon: "<i class='fa fa-check'></i>",
confirmText: '',
showAlways: true,
}),
],
showAlways: false,
theme: 'airbnb',
time_24hr: true,
altInput: true,
altFormat: 'F j, Y H:i',
dateFormat: 'Z',
weekNumbers: true,
minDate: $('#start_time').attr('value'),
onClose: function(selectedDates, dateStr, instance) {
// Change #start_time maxDate
},
});
I tried to play with $('#start_time')[0]._flatpickr.config._maxDate
but without success
Thanks ;)
Hi I'm trying to replace the datetimepicker with flatpickr but I can't handle this situation. Not wishing to use the Range plugin of flatpickr I would like to be able to change the minDate or maxDate of an instance using the onChange event. Unfortunately I found little information about this passage on the guides
flatpickr('#start_time', {
locale: 'it',
enableTime: true,
plugins: [
new confirmDate({
confirmIcon: "<i class='fa fa-check'></i>",
confirmText: '',
showAlways: true,
}),
],
showAlways: false,
theme: 'airbnb',
time_24hr: true,
altInput: true,
altFormat: 'F j, Y H:i',
dateFormat: 'Z',
weekNumbers: true,
maxDate: $('#end_time').attr('value'),
onClose: function(selectedDates, dateStr, instance) {
// Change #end_time minDate
},
});
flatpickr('#end_time', {
locale: 'it',
enableTime: true,
plugins: [
new confirmDate({
confirmIcon: "<i class='fa fa-check'></i>",
confirmText: '',
showAlways: true,
}),
],
showAlways: false,
theme: 'airbnb',
time_24hr: true,
altInput: true,
altFormat: 'F j, Y H:i',
dateFormat: 'Z',
weekNumbers: true,
minDate: $('#start_time').attr('value'),
onClose: function(selectedDates, dateStr, instance) {
// Change #start_time maxDate
},
});
I tried to play with $('#start_time')[0]._flatpickr.config._maxDate
but without success
Thanks ;)
Share Improve this question edited May 21, 2018 at 10:23 Mauro asked May 21, 2018 at 9:30 MauroMauro 1,27123 silver badges27 bronze badges 2- why tag ruby-on-rails? – Jagdeep Singh Commented May 21, 2018 at 9:57
-
the file is a
.js.erb
but I noticed now that there is no rails code. I remove it ;) – Mauro Commented May 21, 2018 at 10:00
1 Answer
Reset to default 7Solved in this way
let startpicker = flatpickr('#start_time', {
locale: 'it',
enableTime: true,
plugins: [
new confirmDate({
confirmIcon: "<i class='fa fa-check'></i>",
confirmText: '',
showAlways: true,
}),
],
showAlways: false,
theme: 'airbnb',
time_24hr: true,
altInput: true,
altFormat: 'F j, Y H:i',
dateFormat: 'Z',
weekNumbers: true,
maxDate: $('#end_time').attr('value'),
onClose: function(selectedDates, dateStr, instance) {
endpicker.set('minDate', dateStr);
},
});
let endpicker = flatpickr('#end_time', {
locale: 'it',
enableTime: true,
plugins: [
new confirmDate({
confirmIcon: "<i class='fa fa-check'></i>",
confirmText: '',
showAlways: true,
}),
],
showAlways: false,
theme: 'airbnb',
time_24hr: true,
altInput: true,
altFormat: 'F j, Y H:i',
dateFormat: 'Z',
weekNumbers: true,
minDate: $('#start_time').attr('value'),
onClose: function(selectedDates, dateStr, instance) {
startpicker.set('maxDate', dateStr);
},
});
本文标签: javascriptFlatpickr change minDate maxDate on the flyStack Overflow
版权声明:本文标题:javascript - Flatpickr change minDate maxDate on the fly - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744033338a2579317.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论