…my table2 updates on page load only but not updating my table values whenever there are changes in my data collection entriesDB…
Using just a dataset-connection : ---->Your SETUP:
----------------------------------------------------------------------
- DATABASE-ID —> “entriesDB”
- Database is connected with —> Dataset (‘#dataset1’)
- Table-ID —> "#table2’ —> also connected to your database (trough ‘#dataset1’)
- Why you talk about BACKEND → i don’t know, maybe because you do not understand the difference between backend and frontend.
However, what do you need and how it will work.
- Whenever you are working on your page → your page first must be ready for work —>…
$w.onReady(()=>{console.log('Page is ready...);});
- Whenever you are using a DATASET → the DATASET also has to be ready first!
$w.onReady(()=>{console.log('Page is ready...);
$w('#dataset1').onReady(()=>{
console.log('Dataset ready...);
console.log('Start of code here....');
//CODE...
//CODE...
//CODE...
//CODE...
//CODE...
//CODE...
console.log('End of code here...');
});
});
- Whenever you save changes into your database by the help of your dataset → 2-hooks will be fired —>…
a) onBeforeSave()-Hook
b) onAfterSave()-Hook
$w.onReady(()=>{console.log('Page is ready...);
$w('#dataset1').onReady(()=>{
console.log('Dataset ready...);
console.log('Start of code here....');
//CODE...
//CODE...
//CODE...
//CODE...
//CODE...
//CODE...
console.log('End of code here...');
});
$w('#dataset1').onBeforeSave(()=>{
//CODE...here what shall happen before data saves!
});
$w('#dataset1').onAfterSave(()=>{
//CODE...here what shall happen after data saved!
});
});
- Now you need a TRIGGER-EVENT, which will start all this process → for example your SUBMIT-BUTTON —> which is also connected to your DATASET !
$w.onReady(()=>{console.log('Page is ready...);
$w('#dataset1').onReady(()=>{
console.log('Dataset ready...);
console.log('Start of code here....');
//CODE...
//CODE...
//CODE...
//CODE...
//CODE...
//CODE...
$w('#mySubmitButtonIDhere').onClick(()=>{
//CODE running when clicked onto SUBMIT-BUTTON!
//This CLICK-ACTION will start onBeforeSave() !
//This also will start onAfterSave(), when data
//has been saved inside your database!
});
console.log('End of code here...');
});
$w('#dataset1').onBeforeSave(()=>{
//CODE...here what shall happen before data saves!
});
$w('#dataset1').onAfterSave(()=>{
//CODE...here what shall happen after data saved!
});
});
Since your SUBMIT-BUTTON is connected to your DATASET, you even do not need the Submitbutton-code-part inside your code, because the click onto the SUBMISSION-BUTTON (which is already connected with your dataset and setted-up inside of the PROPERTY-PANEL) —> it will start both HOOKs → automatically, because your button is setted-up as a —> SUBMISSION → it starts the saving-process by a click onto the button automatically → this calls the 2-Hooks to work.
$w.onReady(()=>{console.log('Page is ready...);
$w('#dataset1').onReady(()=>{
console.log('Dataset ready...);
console.log('Start of code here....');
//CODE...
//CODE...
//CODE...
//CODE...
//CODE...
console.log('End of code here...');
});
$w('#dataset1').onBeforeSave(()=>{
//CODE...here what shall happen before data saves!
});
$w('#dataset1').onAfterSave(()=>{
//CODE...here what shall happen after data saved!
});
});
Now the question!!!
? Do you still need Wix-Data (in your case) ?
The rest of all brainstorming is now on you.
Where to add now which part of code?
Try to imagine what happens in which kind of order?
- First comes the CLICK
- That starts the SAVING
- But BEFORE-SAVING starts → you can do something inside the onBefore-Code-Part…
- Following by the SAVING-PROCESS itself
- And last but not least the AFTER-SAVING-CODE-PART, where you want to UPDATE your DATASET, to show REFRESHED-RESULTS inside of your REPEATER, which is surely also connected to your DATASET.
REFRESHING ??? Did i say → REFRESHING ???
https://www.wix.com/velo/reference/wix-dataset/dataset/refresh
Now try to get this to work with your new KNOWLEDGE.
!!! Good luck and happy coding !!!
!!! May the CODING POWER be with you !!!