I want to run hideSaveCancel() and loadPage() after an array of forms has been iterated, during which, each form will be the subject of an async call to insert/update in the database, initiated by the line postObject.preparePost(formData)
Array.from(document.querySelectorAll('form.dirty')).forEach(
f => {
postObject = new Object();
formData = buildFormDataObject(f);
eval(`postObject = ${f.dataset['jsobj']}`);
postObject.preparePost(formData);
}
)
}).then(() => {
hideSaveCancel();
loadPage(postSavePage, postSaveArgs);
});
I don't understand whether I require multiple promises (one for the array and another for the async calls) or one for the whole process, and ...
I need to understand how to send the "completion" message, so that the hideSaveCancel and loadPage are called after all the form updates have completed.