I have “start” and “end” date fields on a custom page form. Both use the DateTimePicker extension…
loadjs.ready(["fcalendaradd", "datetimepicker"], function () {
let format = "yyyy-MM-dd HH:mm",
options = {
localization: {
locale: ew.LANGUAGE_ID
},
display: {
icons: {
previous: ew.IS_RTL ? "fas fa-chevron-right" : "fas fa-chevron-left",
next: ew.IS_RTL ? "fas fa-chevron-left" : "fas fa-chevron-right"
}
},
meta: {
format,
numberingSystem: ew.getNumberingSystem()
},
stepping: 15
};
ew.createDateTimePicker("fcalendaradd", "start_date", jQuery.extend(true, {"useCurrent":false}, options));
});
I want to link the fields so that the minDate / maxDate values update automatically, so I took this code from the TempusDominus site:
<script type="text/javascript">
$("#start_date").on("change.datetimepicker", function (e) {
$('#end_date').datetimepicker('minDate', e.date);
});
$("#end_date").on("change.datetimepicker", function (e) {
$('#start_date').datetimepicker('maxDate', e.date);
});
</script>
…but I can’t get it to work :(As shown, the browser console reports that “.datetimepicker” is not a function, so I tried changing “.datetimepicker” to “.tempusdominus”, but that generated this:
Uncaught Error: TD:: ".0" in not a known option.Did you mean "viewDate.nonLeapLadder.0"?, ".1" in not a known option.Did you mean "viewDate.nonLeapLadder.1"?, ".2" in not a known option.Did you mean "viewDate.nonLeapLadder.2"?, ".3" in not a known option.Did you mean "viewDate.nonLeapLadder.3"?, ".4" in not a known option.Did you mean "viewDate.nonLeapLadder.4"?, ".5" in not a known option.Did you mean "viewDate.nonLeapLadder.5"?, ".6" in not a known option.Did you mean "viewDate.nonLeapLadder.6"?
at ErrorMessages.unexpectedOptions (tempus-dominus.js:462:27)
at l (tempus-dominus.js:1587:45)
at Function._mergeOptions (tempus-dominus.js:1617:13)
at TempusDominus._initializeOptions (tempus-dominus.js:3347:38)
at new TempusDominus (tempus-dominus.js:3142:34)
at Object.jQueryHandleThis (tempus-dominus.js:3539:16)
at S.fn.init.jQueryInterface [as tempusDominus] (tempus-dominus.js:3524:30)
at HTMLInputElement.<anonymous> (calendar:449:17)
at HTMLInputElement.dispatch (jquery-3.6.0.min.js:2:43064)
at HTMLInputElement.v.handle (jquery-3.6.0.min.js:2:41048)
TdError @ tempus-dominus.js:428
unexpectedOptions @ tempus-dominus.js:462
l @ tempus-dominus.js:1587
_mergeOptions @ tempus-dominus.js:1617
_initializeOptions @ tempus-dominus.js:3347
TempusDominus @ tempus-dominus.js:3142
jQueryHandleThis @ tempus-dominus.js:3539
jQueryInterface @ tempus-dominus.js:3524
(anonymous) @ calendar:449
...
Can anyone point me in the right direction?