I have checked all other posts I could find on this forum and none of the solutions has worked for me.
-
I have confirmed permissions on the collection and the datasets
-
I have the .Onready statement in my code
-
I have synced the sandbox to the live table
My site is www.gembcla.org/pray
I have separate input and output pages and datasets for each. The code on my page is listed below.
import wixdata from 'wix-data';
function getData(){
let query = wixdata.query ("#prayersread");
return query.limit(1000).find().then(results => {
console.log('getdata', results);
return results.items;
});
}
export function button5_click(event) {
$w("#prayerswrite").save()
}
$w.onReady( () => {
$w("#prayerswrite").onAfterSave( () => {
getData().then((items)=> {
$w("#prayerlist").data = items;
});
});
});
Any help is appreciated!!!
First off, do you actually need the button 5 in your code as assuming that this is the ‘Submit Request’ button on the prayer submit form.
This can easily just be setup with the button being connected directly to the dataset itself to save it and then you won’t need to use the save function in your code.
https://support.wix.com/en/article/adding-a-submit-button-to-your-form
Then in theory your code could be shuffled and the onAfterSave can be placed at the top for the code to run after the form has been submitted and saved into your dataset.
Something simple like this…
import wixdata from 'wix-data';
$w.onReady(function () {
$w("#prayerswrite").onAfterSave(() => {
getData().then((items) => {
$w("#prayerlist").data = items;
});
});
});
function getData() {
let query = wixdata.query("#prayersread");
return query.limit(1000).find().then(results => {
console.log('getdata', results);
return results.items;
});
}
Thanks for the suggestion, but it still does not show the live data. It works perfectly in Editor. I’m not sure what I’m missing.