Hotwire Discussion

Stimulus controller not connecting inside of lazy loaded turbo frame

I have been working on a messaging app using hotwire, Im trying to use a stimulus controller on a message partial getting rendered inside of a turbo frame for the chat. I need to scroll down a div every time a new message is received but the stimulus controller is not connecting to page.
this is code inside _message.html.erb. Im using stimulus inside of asset pipeline another issue im having with it is Im not able to write a multiple word controller or it says Failed to autoload controller: hello-world. Would appreciate any help if anyone knows the solution. I looked at other posts and couldn’t find any answers regarding this.

    <%= turbo_frame_tag dom_id(message) do %>
      <div class="w-full bg-gray-400 min-h-10 pl-4 py-2" data-controller="message">
      <h3 class="text-lg"> <%= message.content %> </h3>
      <p class="text-gray-700 text-sm"> <%= message.user.username %> <%= time_ago_in_words(message.created_at) %> ago </p>
    <% end %>

code on page rendering messages

<div class="h-full w-4/5 ml-auto" data-controller="messages">
  <%= turbo_frame_tag "messages", src: room_messages_path(@room) do %>
  <% end %>
</div>
2 Likes

looks like the problem is getting fixed in a new update to stimulus Turbo lazy loading not connecting stimulus controller · Issue #47 · hotwired/turbo · GitHub