# Is setting turbo frame src in stimulus controller bad practice?

**URL:** <https://discuss.hotwired.dev/t/is-setting-turbo-frame-src-in-stimulus-controller-bad-practice/5458>\
**Category:** General\
**Created:** [November 23, 2023, 9:14am UTC](https://discuss.hotwired.dev/t/is-setting-turbo-frame-src-in-stimulus-controller-bad-practice/5458 "2023-11-23T09:14:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![artur79](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/artur79/32/1960_2.png) [@artur79](https://discuss.hotwired.dev/u/artur79)\
**Post date:** [November 23, 2023, 9:14am UTC](https://discuss.hotwired.dev/t/is-setting-turbo-frame-src-in-stimulus-controller-bad-practice/5458/1 "2023-11-23T09:14:54Z")

</div>

According to chat gpt:

> Turbo Frames in Rails typically work by sending requests to the server, and the server responds with the updated content for the frame. If you’re manually updating the `src` attribute of a Turbo Frame and expecting it to reload, it might not work as expected because Turbo Frames rely on Turbo Streams to provide the updated content.

---

<div class="post-metadata">

**Author:** ![mtomov](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/mtomov/32/1182_2.png) [@mtomov](https://discuss.hotwired.dev/u/mtomov)\
**Post date:** [November 24, 2023, 9:36am UTC](https://discuss.hotwired.dev/t/is-setting-turbo-frame-src-in-stimulus-controller-bad-practice/5458/2 "2023-11-24T09:36:51Z")

</div>

> Turbo Frames rely on Turbo Streams to provide the updated content.

This is not correct.

Setting `src` attribute via JS to control a turbo frame is a standard practice.

---

<div class="post-metadata">

**Author:** ![artur79](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/artur79/32/1960_2.png) [@artur79](https://discuss.hotwired.dev/u/artur79)\
**Post date:** [November 24, 2023, 9:52am UTC](https://discuss.hotwired.dev/t/is-setting-turbo-frame-src-in-stimulus-controller-bad-practice/5458/3 "2023-11-24T09:52:55Z")

</div>

thanks, I think in my case I blamed frame’ src set but the problem was that I still had turbolinks on 🙂

---

<div class="post-metadata">

**Author:** ![marco-beduschi](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/marco-beduschi/32/2927_2.png) [@marco-beduschi](https://discuss.hotwired.dev/u/marco-beduschi)\
**Post date:** [November 29, 2023, 7:29pm UTC](https://discuss.hotwired.dev/t/is-setting-turbo-frame-src-in-stimulus-controller-bad-practice/5458/4 "2023-11-29T19:29:09Z")

</div>

You can set ‘src’ with JS, no problem. The “only” thing turbo does is intercept the form request and read from ‘src’ to realize where to send data. It doesnt matter if you change it a thousand times, it only cares about the attribute when the form is submitted!
