# Refresh a frame programmatically

**URL:** <https://discuss.hotwired.dev/t/refresh-a-frame-programmatically/1602>\
**Category:** General\
**Created:** [December 23, 2020, 6:49pm UTC](https://discuss.hotwired.dev/t/refresh-a-frame-programmatically/1602 "2020-12-23T18:49:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![virk](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/virk/32/1107_2.png) [@virk](https://discuss.hotwired.dev/u/virk)\
**Post date:** [December 23, 2020, 6:49pm UTC](https://discuss.hotwired.dev/t/refresh-a-frame-programmatically/1602/1 "2020-12-23T18:49:52Z")

</div>

Lets imagine I have a page with 2 frames on it.

- One to display a list of items
- Other is a form to create that item

Post form submission, I want to trigger a refresh on the frame holding the list of items.

One option is to return a stream from the form submission response that appends to the list. But in that case I am hard wiring my form responses to be aware of a turbo app + the navigation style.

Instead, I want form submission to be its own thing. Submit form + redirect. Job done and then the frontend using stimulus to trigger a refresh on the list frame

---

<div class="post-metadata">

**Author:** ![jonathanbruno](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/jonathanbruno/32/1215_2.png) [@jonathanbruno](https://discuss.hotwired.dev/u/jonathanbruno)\
**Post date:** [December 29, 2020, 4:25pm UTC](https://discuss.hotwired.dev/t/refresh-a-frame-programmatically/1602/2 "2020-12-29T16:25:31Z")

</div>

I’d do this using a turbo\_stream.erb file, it feels like the turbo\_stream format are navigation aware. It’s kinda hard do reuse that same turbo\_stream response for different navigation purposes

---

<div class="post-metadata">

**Author:** ![blueplanet](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/blueplanet/32/1361_2.png) [@blueplanet](https://discuss.hotwired.dev/u/blueplanet)\
**Post date:** [January 5, 2021, 11:07am UTC](https://discuss.hotwired.dev/t/refresh-a-frame-programmatically/1602/3 "2021-01-05T11:07:17Z")

</div>

@virk @jonathanbruno  
I created ‘hotwrie-scaffold’ .  
This is SPA for scaffold with form in index view.

> **[blueplanet/hotwire-scaffold](https://github.com/blueplanet/hotwire-scaffold)**
>
> Contribute to blueplanet/hotwire-scaffold development by creating an account on GitHub.

Points:

- index.html.erb

```auto
<%= turbo_frame_tag 'post_form', src: new_post_path, target: 'post_form' %>

```

- new.html.erb:

```auto
<%= turbo_frame_tag 'post_form' do %>
  <h2>New Post</h2>
  <%= render 'form', post: @post %>
<% end %>

```
