Topic: Dynamically set Date with JS in Datepicker
travel2fit premium asked 5 months ago
Expected behavior Per documentation API : Using the "update" method you can change the values of the options. According to that , changing the value of the defaultDate should be achieved with the following code :
myDatePicker.update({defaultDate: newDate});
setting the "min" though works without issues (even though the "min" option is not mentioned in the documentated options which generally happens quite often in the documentation):
toDate.update({min: e.date});
Actual behavior Does not do anything
Resources (screenshots, code snippets etc.)
let fromDate = new mdb.Datepicker(document.querySelector('.datepicker-from'), {
min: new Date(),
format: 'yyyy-mm-dd'
});
let toDate = new mdb.Datepicker(document.querySelector('.datepicker-to'), {
format: 'yyyy-mm-dd'
});
document.addEventListener('valueChanged.mdb.datepicker', (e) => {
toDate.update({defaultDate: e.date});
});
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Premium
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 7.2.0
- Device: PC
- Browser: EDGE
- OS: windows 10
- Provided sample code: No
- Provided link: No