@stc1705 Ok, after taking a look onto your code, i am able to say, that you must be relatively new to coding.
There are some issues in your code, also mixing DATASET-CODE with Wix-Data-code is not one of the best ideas. You better go either the one or the other way.
However, let’s switch to the issued code-lines…
This is aproxiatively how your code should look like…
import wixData from 'wix-data';
$w.onReady(async()=>{
let foundResults = await getData('Comments'); console.log("RESULTS: ", foundResults);
$w('#dataset2').onAfterSave(() => {
getData().then((items) => {
$w('#dataset3').data = items;
});
});
});
function getData() {
return wixData.query(DB)
.limit(1000)
.find()
.then((res)=>{return res;})
.catch((err)=>{console.log("ERROR occured!");});
}
- On top you have all library imports
- You always start your code with $w.onReady());
- Functions should always be placed either to the right related code-line ot to the very end of your code. (but not neccessary.
And my most important tip for you… always take a look onto the VELO-API, to get info of all currently used elements.
Whats going on here…?
$w('#dataset3').data = items; >--- maybe using a REPEATER here, would be better?)
Does .data somewhere exists inside dataset-api? Please check first.
But still something wrong with this code!!!
You said you need some actions when clicking the Submit-button ?
The action is already given and the SUBMIT-BUTTON even do not have to be coded.
You click the SUBMIT-BUTTON → some saving prozesses starts, right?
And what happens next?
$w('#dataset2').onAfterSave(() => {
getData().then((items) => {
$w('#repeater3').data = items;
});
});
Yes onAfterSave should run after saving-process.
Or i am today just overworked…to be continued! ![]()