I am working on an alternative datepicker for Wix Code, that allows different languages, time-picker etc. I have got it 99.9% working. The non-working part is about this:
inside the html-comp the calendar is drawn with settings inside some jQuery-code;
a bit after this drawing is done, from postMessage comes the date to display in the calendar as defaultDate. This date arrives perfectly.
now, in a already drawn calendar, I need to reset the defaultDate property with the date that just arrived.
And here my stupidity shines: I cannot do it, whatever I try.
So, is someone willing to help me out. I have tried on StackOverflow, but no response, the combination Wix Code/jQuery/postmessage/flatpickr is too rare, I fear.
Uh no, I think, Andreas. The property is called "defaultDate’ and must be reset to the date the came in thru postMessage. I posted the html part on Stackoverflow. Here is the link:
The part
if (event.data) { $(“#startDate”).flatpickr.defaultDate = event.data; }
is what should set the date in the datepicker, but obviously, it doesn´t, I know zilch about jQuery. Event.date holds the correct date, but I cannot for the life of me get that into the defaultDate property that is already set at the end (and drawn before event.data arrives).
Thanks.
Andreas, the onReady is fired when the datepickr is drawn. But the date thru postmessage arrives later, a lot later. So as far as I can see, the only place I can set the date is where I put it, in the onMessage. But I do not lnow how to reference the faltpickr instance from there.
Ok, when you load the html component set it up in the onReady, make a function that will re init the calendar and when the html component has been loaded in the onready send a postMessage back to Wix Code, take the date and send it into the html component and re init the calendar. Works? I had to do this with my Google Maps Integration on aroundme.ai.
Andreas, I found your latest contribution after I posted the “It works”, but thanks anyway. I solved it in a different way: wrapped a function around the datepicker init and call it from the onMessage with the date. Works well.
Thanks for your help, seems real help is coming from less and less contributors on this forum, but am glad you are still watching it.
Yes, I think that Wix should actually employ someone to hep people here. There are a few that helps, I try to be in here at least once a day but sometimes I have to prio my projects Send that to Wix so we are more people that wants this.