Using MaterializeCSS 1 rc2, I try to update the date of my DatePicker from Javascript.
My HTML
<form action="#" novalidate>
<input type="text" class="datepicker" name="date" id="datepicker">
</form>
My JS
function changeDate(date) {
/* date is a javascript Date object */
var datepicker = document.getElementById('datepicker');
var instance = M.Datepicker.getInstance(datepicker);
instance.setDate(date);
}
Looking at the console, all the variables are set to their expected value. When I click on the DatePicker, that's also the expected date which is displayed (the one I use in changeDate
). But the text in the input field does not change...
My friend, you have found a bug in MaterializeCSS!
I can suggest you my workaround: call instance._finishSelection()
after calling instance.setDate()
to see your changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With