I’m trying to populate a value for a date picker in a page’s $w . onReady function. The code is very simple.
$w('#datePicker1').value = new Date("2022-09-15");
This works if the date picker’s default value is set to “Today”. If I change the default to “Nothing” or “Placeholder text”, the value I set in code seems to get overwritten during loading and the value ends up being “null”. If I wait 1 second before setting the value, it works as expected.
setTimeout(()=> { $w('#datePicker1').value = new Date("2022-09-15"); }, 1000);
The date picker doesn’t have its own onReady function to see if it’s done setting the default value.
Conversely, if I want to set the date picker to be blank, but the default is set to “Today”, it puts today’s date in there after I cleared it in the $w.onReady function.
It seems like the problem is that the date picker is getting it’s default value set after or during the onReady, not before. And it takes almost half a second to complete.