DatePicker element stays empty after setFieldValues() is called

Hello,
In a dataset onReady I am setting values on another dataset using $w(“#dsInscricao”).setFieldValues() for a bunch of fields. These fields are all linked to textboxes on the page. All of them get populated on the screen after that setFieldValues call, except for a DatePicker. That stays empty. No error, just it doesn’t get populated. I have another page with the same DatePicker that doesn’t populate when record comes straight from the db. Data type on the DB is date without time. I tried with time, same issue.
At this point I am assuming this is a bug.

Product:
Wix Editor in Preview Mode

I’d appreciate if anyone could share an insight and if Wix could weigh in.

I’m not able to reproduce at least in this simple case. Example site here: https://anthonyl5.wixstudio.io/my-site-183

$w.onReady(function () {
    const date = new Date(new Date().valueOf() - Math.random()*(1e+12));
    $w('#dataset1').onReady(() => {
        $w('#dataset1').setFieldValues({
            date
        })
    })
});

One possibility is that because you’re setting values in one dataset from another dataset the other dataset isn’t actually ready when setFieldValues is called. May want to see if something like this works for you:

$w.onReady(async function () {
    const date = new Date(new Date().valueOf() - Math.random()*(1e+12));
    $w('#dataset1').onReady(() => {
        await $w('#otherDataset').onReadyAsync();
        $w('#otherDataset').setFieldValues({
            date
        })
    })
});

Another possibility is that the date picker wasn’t bound to a field in the editor.

If not can you share code that reproduces the issue?

Thanks for looking into this, @anthony.
I mentioned I have 2 pages: 1 is simple datepicker bound to the date field and the other is loaded from a different dataset with setFieldValues. And neither of them work, for this field only. All the other bound fields are fine.
Funny fact: if I try to get the value using $w(“#datepicker”), it has it. And, after previewing the page, when I click the “Back to Editor” button, the date shows in the field briefly before the screen goes back to edit mode!!!

I think I got the issue… change initial text to “Nothing” and see if it still works. Once I changed to “Today’s date” it worked fine and loaded the date from the db. “Placeholder text” also doesn’t work. Thank you.

image

1 Like

Interesting. Will share with the team. Thanks for figuring out the cause of the issue!

1 Like

2 posts were split to a new topic: Preview runs as admin but this is not clear

Question. Which editor is this in? I’m unable to reproduce in Wix Studio.