I have a repeater that displays a list of businesses. The repeater is connected to a ReadOnly dataset. The user can click an edit button on the repeater to display a form for editing. The form fields are connected to a Read&Write dataset. Both datasets are for the same collection. When the user clicks submit, the data saves correctly, but I have to use setTimeout to get the repeater to refresh.
Repeater connected to datasetList (this is ReadOnly from ‘businesses’ collection)
Form connected to datasetForm (this is Read&Write from ‘businesses’ collection)
//This works
export async function submit_click(event) {
$w("#businessFormContainer").hide()
await $w("#datasetForm").save()
setTimeout(()=>{$w("#datasetList").refresh()},100)
}
//This does not work
export async function submit_click(event) {
$w("#businessFormContainer").hide()
await $w("#datasetForm").save()
$w("#datasetList").refresh()
}
//This does not work
export function submit_click(event) {
$w("#businessFormContainer").hide()
$w("#datasetForm")
.save()
.then(() =>
$w("#datasetList").refresh()
)
}
Why do I need to use setTimeout? I shouldn’t be fetching the data for datasetList until the update is finished? I would love to find a way to do this properly with promises instead of this work around.