# Delaying a Refresh Dataset 

**URL:** <https://forum.wixstudio.com/t/delaying-a-refresh-dataset/9377>\
**Category:** Ask the community\
**Tags:** question, code, design, wix-members-area\
**Created:** [January 21, 2022, 7:06pm UTC](https://forum.wixstudio.com/t/delaying-a-refresh-dataset/9377 "2022-01-21T19:06:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikkelhmogensen](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mikkelhmogensen/32/31839_2.png) [@mikkelhmogensen](https://forum.wixstudio.com/u/mikkelhmogensen)\
**Post date:** [January 21, 2022, 7:06pm UTC](https://forum.wixstudio.com/t/delaying-a-refresh-dataset/9377/1 "2022-01-21T19:06:54Z")

</div>

Hello,  
this should be really easy but I just can’t figure out how to do it.

I’m making a staff page where you put in some information in a form and the dataset shown in the bottom refreshes and shows what you’ve submitted.

so what I’m trying to do is.

when my staff members click “Submit” the button should upload the content (which

it does) and after 500 ms it should refresh my dataset.

I have tried this

**const** myTimeout = setTimeout ( button17\_click ( 1000 )

export function button17\_click ( event ) {  
// Refresh to load more data into dataset  
$w ( ‘#dataset2’ ). refresh ();  
}

but i’m not sure what I’m doing wrong

can anyone help 🙂

here’s a picture of the design for now

 ![](https://us1.discourse-cdn.com/wix/original/3X/4/a/4aa6e5d6d324e44b34e1a1a0c43355b3f4beac7c.png)

---

<div class="post-metadata">

**Author:** ![amandam](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/amandam/32/79539_2.png) [@amandam](https://forum.wixstudio.com/u/amandam)\
**Post date:** [January 21, 2022, 10:09pm UTC](https://forum.wixstudio.com/t/delaying-a-refresh-dataset/9377/2 "2022-01-21T22:09:29Z")

</div>

Hello. Have you tried running a query to whatever is populating that dataset instead of using refresh? My assumption here is that the submit is updating your collection and what you need to do is query the collection again to populate the repeater.

---

<div class="post-metadata">

**Author:** ![mikkelhmogensen](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mikkelhmogensen/32/31839_2.png) [@mikkelhmogensen](https://forum.wixstudio.com/u/mikkelhmogensen)\
**Post date:** [January 21, 2022, 10:19pm UTC](https://forum.wixstudio.com/t/delaying-a-refresh-dataset/9377/3 "2022-01-21T22:19:11Z")

</div>

what happens is when they upload data to the dataset, the repeater underneath dosen’t update, unless they press my update button, what I want is just when they hit submit, the dataset refreshed a few seconds afterwards so my client can see the update

---

<div class="post-metadata">

**Author:** ![robmich](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/robmich/32/24414_2.png) [@robmich](https://forum.wixstudio.com/u/robmich)\
**Post date:** [January 22, 2022, 9:22pm UTC](https://forum.wixstudio.com/t/delaying-a-refresh-dataset/9377/4 "2022-01-22T21:22:08Z")

</div>

@mikkelhmogensen A better approach would be to not connect the button to the dataset submit and handle it all in code. So what you would do:

1. Remove the connection between the submit button and the dataset submit property.

2. Add the following code to the $w.onReady() section:  
$w (“#NameOfTheSubmitButton”). onClick (( event ) =\> {  
$w ( ‘#dataset2’ ).save()  
.then ((response) =\> {  
// data saved!  
$w ( ‘#dataset2’ ).refresh()   
})  
.catch ((error) =\> {  
// Error saving data  
console.log(error);  
})  
});

When the submit button is clicked, this code will save the dataset record and then call the refresh after the save has successfully completed. This way you don’t need to mess around with time delays or multiple events.

---

<div class="post-metadata">

**Author:** ![amandam](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/amandam/32/79539_2.png) [@amandam](https://forum.wixstudio.com/u/amandam)\
**Post date:** [January 24, 2022, 1:40pm UTC](https://forum.wixstudio.com/t/delaying-a-refresh-dataset/9377/5 "2022-01-24T13:40:34Z")

</div>

@robmich Great suggestion. Thanks for weighing in!

---

<div class="post-metadata">

**Author:** ![mikkelhmogensen](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mikkelhmogensen/32/31839_2.png) [@mikkelhmogensen](https://forum.wixstudio.com/u/mikkelhmogensen)\
**Post date:** [January 24, 2022, 5:05pm UTC](https://forum.wixstudio.com/t/delaying-a-refresh-dataset/9377/6 "2022-01-24T17:05:55Z")

</div>

@robmich Thanks man! I’ll have a look 🙂

---

<div class="post-metadata">

**Author:** ![mikkelhmogensen](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mikkelhmogensen/32/31839_2.png) [@mikkelhmogensen](https://forum.wixstudio.com/u/mikkelhmogensen)\
**Post date:** [January 24, 2022, 6:22pm UTC](https://forum.wixstudio.com/t/delaying-a-refresh-dataset/9377/7 "2022-01-24T18:22:58Z")

</div>

@mikkelhmogensen Its Working as intended! Thank you very much!

---

<div class="post-metadata">

**Author:** ![mikkelhmogensen](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mikkelhmogensen/32/31839_2.png) [@mikkelhmogensen](https://forum.wixstudio.com/u/mikkelhmogensen)\
**Post date:** [January 24, 2022, 6:23pm UTC](https://forum.wixstudio.com/t/delaying-a-refresh-dataset/9377/8 "2022-01-24T18:23:18Z")

</div>

@robmich It’s working as intended!! Thank you very much!
