Hotwire Discussion

Turbo-frame doesn't display a content

Hi folks. I have a simple index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Hotwire test</title>

  <script src="https://cdn.skypack.dev/@hotwired/turbo?min" type="module"></script>
</head>
<body>
  <turbo-frame id="messages" src="/messages">
    <div><strong>no messages</strong></div>
  </turbo-frame>
</body>
</html>

and a /messages handler returns smth like this with content type in header

  <turbo-frame id="messages">
    <div>one</div><div>two</div><div>three</div>
  </turbo-frame>

I really don’t understand why the page changes only if a /messages handler returns:

  <html>
  <turbo-frame id="messages">
    {{range .Messages}}<div>{{ . }}</div>{{end}}
  </turbo-frame>
  </html>

I don’t understand your doubt, the initial frame tag id must match the response frame tag id

Thanks for answer. I don’t understand why I can not return from /messages a turbo-frame as is but should wrap it in tag. turbo-frame in index.html and as answer from /messages have same id.

It was my bad. I solved.