# How to auto-reload frame?

**URL:** <https://discuss.hotwired.dev/t/how-to-auto-reload-frame/1872>\
**Category:** General\
**Created:** [January 5, 2021, 12:27pm UTC](https://discuss.hotwired.dev/t/how-to-auto-reload-frame/1872 "2021-01-05T12:27:20Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ledermann](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/ledermann/32/1320_2.png) [@ledermann](https://discuss.hotwired.dev/u/ledermann)\
**Post date:** [January 6, 2021, 8:30am UTC](https://discuss.hotwired.dev/t/how-to-auto-reload-frame/1872/5 "2021-01-06T08:30:36Z")

</div>

Thanks a lot, @stgm, setting the `src` attribute to trigger a reload works fine!

Now I’ve made this Stimulus.js controller:

```javascript
// app/javascript/controllers/refresh_controller.js
import { Controller } from "stimulus"

export default class extends Controller {
  static values = {
    src: String
  }

  connect() {
    this.timeout = setTimeout(() => {
      this.element.setAttribute('src', this.srcValue)
    }, 5000);
  }

  disconnect() {
    clearTimeout(this.timeout)
  }
}

```

Usage in a Rails partial:

```auto
<%= turbo_frame_tag 'stats', 
      data: { controller: 'refresh', refresh_src_value: request.path } do %>
  <p>Updated content</p>
<% end %>

```

---

_[View the full topic](https://discuss.hotwired.dev/t/how-to-auto-reload-frame/1872)._
