onclick - submit data and reload the page - how to?

Hi there,
I would like to add a button at the end of my form - that will submit the data AND will refresh the same page with the newly added data - or will reload the dataset in this page.
https://www.hadid.co.il/pictures
(when a new picture is added…)/

thanks,
Liron.

Hi Liron,

Disconnect the button from the dataset, add a onClick event and use the following code:


export function savebutton_click(event, $w) {
	$w("#dataset").save()
		.then( => {
			$w("#dataset").refresh();
		})
		.catch((err) => {
			let errMsg = err;
		});
}
4 Likes

The above code doesn’t seem to be working - it has a unexpected token. Any suggestions?

Screenshots:
CloudApp
CloudApp

Hi,
You need to change the string inside the parentheses to your dataset’s name, you can see each elements name in the properties panel.


Good luck :slight_smile:

I’m also looking for something similiar

  • i have done the above code and am still having issues even after I replace the dataset with my own dataset

=> is the part of the code with the error message, any suggestions? Thank you in advance! Any help is appreciated!

there is a syntax mistake in the code above:
use this
.then ( ( ) => {
instead of this
.then ( => {

5 Likes