jbb
November 16, 2020, 10:58pm
1
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
javan
November 17, 2020, 1:08pm
2
Target elements need to be contained by their controller element, and I’m guessing you’re rendering those partials outside of it (via content_for
→ yield
)? e.g.:
<%= yield :actions %>
…
<div data-controller="transfer">
<%= content_for :actions do %>
<%= render partial: 'actions', locals: {form: f} %>
<% end %>
…
</div>
jbb
November 17, 2020, 8:09pm
3
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