Data-controller and partials | Solved

:wave: My stimulus controller doesn’t connect to any data-action or data-target I use inside the partials I render.

  <div data-controller="transfer">

    <%= content_for :actions do %>
      <%= render partial: 'actions', locals: {form: f} %>
    <% end %>

    <%= content_for :content do %>
      <%= render partial: 'table' %>
    <% end %>

  </div>

How to make it work?

Thanks :pray:

Target elements need to be contained by their controller element, and I’m guessing you’re rendering those partials outside of it (via content_foryield)? e.g.:

<%= yield :actions %>
…
<div data-controller="transfer">
  <%= content_for :actions do %>
    <%= render partial: 'actions', locals: {form: f} %>
  <% end %>
  …
</div>

Thx Javan,

You are right, the problem is not due to partials but to the fact I have two content_for.

I’ll change that