# Auto refresh tables code

**URL:** <https://forums.knack.com/t/auto-refresh-tables-code/7127>\
**Category:** Ask Developers\
**Created:** [April 8, 2018, 11:45pm UTC](https://forums.knack.com/t/auto-refresh-tables-code/7127 "2018-04-08T23:45:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guilhermeb42087](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@Guilhermeb42087](https://forums.knack.com/u/Guilhermeb42087)\
**Post date:** [April 8, 2018, 11:45pm UTC](https://forums.knack.com/t/auto-refresh-tables-code/7127/1 "2018-04-08T23:45:03Z")

</div>

Hey Guys,

Can anyone help me sharing a code in order to auto refresh tables (#view\_1111 and #view\_1100) after 5 minutes?

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![Guilhermeb42087](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@Guilhermeb42087](https://forums.knack.com/u/Guilhermeb42087)\
**Post date:** [April 16, 2018, 11:39pm UTC](https://forums.knack.com/t/auto-refresh-tables-code/7127/2 "2018-04-16T23:39:09Z")

</div>

Would you mind to compile the code for me with your suggestion? I dont know how to do it.

---

<div class="post-metadata">

**Author:** ![JulianSwal22288](https://avatars.discourse-cdn.com/v4/letter/j/8c91f0/32.png) [@JulianSwal22288](https://forums.knack.com/u/JulianSwal22288)\
**Post date:** [April 16, 2018, 11:36pm UTC](https://forums.knack.com/t/auto-refresh-tables-code/7127/3 "2018-04-16T23:36:56Z")

</div>

Wrap you model.fetch in a timer...

function doSomething() {

alert('This is a 5 minute popup');

}

setInterval(doSomething, 300000);

I know this isn't your code, but a way to do it maybe?

So, on the view load set the timer, and in the doSomethign have your model.fetch() code is my thought.

---

<div class="post-metadata">

**Author:** ![Guilhermeb42087](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@Guilhermeb42087](https://forums.knack.com/u/Guilhermeb42087)\
**Post date:** [April 16, 2018, 10:04pm UTC](https://forums.knack.com/t/auto-refresh-tables-code/7127/4 "2018-04-16T22:04:16Z")

</div>

The result I want is the one I get with this code

$(document).on('knack-cell-update.view\_1111', function(event, view, record) {  
Knack.views["view\_1111"].model.fetch();

});

However, the code above only works when inline edit a cell. I want this kind of refresh of the table in view\_1111.

Is this possible?

---

<div class="post-metadata">

**Author:** ![Guilhermeb42087](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@Guilhermeb42087](https://forums.knack.com/u/Guilhermeb42087)\
**Post date:** [April 16, 2018, 9:57pm UTC](https://forums.knack.com/t/auto-refresh-tables-code/7127/5 "2018-04-16T21:57:35Z")

</div>

I mean view\_1111

---

<div class="post-metadata">

**Author:** ![Guilhermeb42087](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@Guilhermeb42087](https://forums.knack.com/u/Guilhermeb42087)\
**Post date:** [April 16, 2018, 9:52pm UTC](https://forums.knack.com/t/auto-refresh-tables-code/7127/6 "2018-04-16T21:52:48Z")

</div>

Nice! Just need to fix the " for '. However, will refresh the hole page and I would like to refresh only the table in view\_1118

---

<div class="post-metadata">

**Author:** ![JulianSwal22288](https://avatars.discourse-cdn.com/v4/letter/j/8c91f0/32.png) [@JulianSwal22288](https://forums.knack.com/u/JulianSwal22288)\
**Post date:** [April 16, 2018, 9:31pm UTC](https://forums.knack.com/t/auto-refresh-tables-code/7127/7 "2018-04-16T21:31:40Z")

</div>

I'd do this with a little java script function linked to when these pages are loaded.. Something like the below.. I haven't tested it..

$(document).on('knack-view-render.view\_1111', function(event, view, data) {

var timeoutPeriod = 300000;

setTimeout('location.reload(true);",timeoutPeriod);  
  
});

---

<div class="post-metadata">

**Author:** ![NormandDefayette\_CortexRD](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/normanddefayette_cortexrd/32/855_2.png) [@NormandDefayette\_CortexRD](https://forums.knack.com/u/NormandDefayette_CortexRD)\
**Post date:** [December 21, 2022, 11:22pm UTC](https://forums.knack.com/t/auto-refresh-tables-code/7127/8 "2022-12-21T23:22:50Z")

</div>

Here’s the best solution you can imagine!!

See for yourself here: [https://forums.knack.com/t/auto-refreshing-tables/9675/4](https://forums.knack.com/t/auto-refreshing-tables/9675/4)

Have fun,  
Norm
