The problem I have is that once you hit the “submit a testimonial” button from a lightbox. You then need to refresh the temimonial page in order to see it.
Now there is no fuction for this refresh. So is there any code for it ? Im not a coder as most on here are
www.dragonnight.com.au
I did find this code. Its not what I want as it refreshs the page every 5 sec.
Just want something that does it once.
And would the code be attached o the button on the lightbox ?
import wixLocation from ‘wix-location’ ;
export function button2_click ( event ) { $w ( ‘#dataset1’ ). save ();
setTimeout (() => {
wixLocation . to ( “/testiomonials” );
}, 1000 );
}
This code is in the lightbox
so this is where i am at. But I still dont have my testinmonial page reloading up with the new testimonial
I have worked it.
this is the final code which is in the lightbox
import wixLocation from ‘wix-location’ ;
export function button2_click ( event ) { $w ( ‘#dataset1’ ). save ();
setTimeout (() => {
wixLocation . to ( “https://www.dragonnight.com.au/testimonials” );
}, 1000 );
}
Hi there,
Refreshing the page every X seconds isn’t a solution at all, what you need to do is open the lightbox with code and close it with code too, this way you can tell whether the new testimonial has been submitted or not.
// The Testimonials page
import window from 'wix-window';
$w.onReady(() => {
$w('#addTest').onClick(() => {
// Open the lighbox when the "Add Testimonial" button is clicked
window.openLightbox('Add Testimonial').then((configs) => {
// Check if the lighbox was closed after a sucessful submittion or not
if (configs.submitted) {
// Now refresh the page, or better, refresh the content
/* If you're using a dataset, refresh the dataset.
if you're using code, call your function again to fetch
the new data */
$w('#dataset').refresh();
}
})
})
})
// Lighbox page
import window from 'wix-window';
const config = { submitted: false }
$w.onReady(() => {
/* Once the submission is completed, return the status as a config. object to
the original page. I'll assume you're using a dataset too */
$w("#dataset").onAfterSave(() => {
// Change the configs.
config.submitted = true;
// Close the lighbox.
window.lightbox.close(config);
});
})
Here you have it.
Hope this helps!~
Ahmad