etmartinkazoo
Joined 12/15/2022
etmartinkazoo said about 2 years ago on Dynamic Select Forms with Hotwire :
Great episode, thank you.

I cannot seem to get this working. It is throwing a:

Error invoking action "change->dynamic-select#updateProjects"

Error: Missing target element "secondarySelect" for "dynamic-select" controller

I am running the latest version of Rails and wondering if something has changed since you made this episode...?

etmartinkazoo said about 2 years ago on Dynamic Select Forms with Hotwire :
Woah, thanks for the quick response!

I do have that in place. My code is:
<div data-controller="dynamic-select" data-dynamic-select-url-value="<%= filtered_projects_organizations_path %>" data-dynamic-select-selected-value="<%= task.project_id %>"
    >
        <%= form.label :organization_id %>
        <%= form.select :organization_id,
          Organization.all.map { |o| [o.name, o.id] },
          { prompt: 'Please select an organization' },
          {
            "data-action": "change->dynamic-select#updateProjects",
            "data-dynamic-select-target": "mainSelect"
          }
        %>
      </div>
      <div>
        <%= form.label :project_id %>
        <%= form.select :project_id,
          [],
          { prompt: 'Please select a project' },
          {
            "data-dynamic-select-target": "secondarySelect"
          }
        %>
      </div>

etmartinkazoo said about 2 years ago on Dynamic Select Forms with Hotwire :
It looks like it is set:

etmartinkazoo said about 2 years ago on Dynamic Select Forms with Hotwire :
LOL, code is always humbling and in the immortal words of Chris Farley, "Idiot!" I can't believe it was that simple. I truly appreciate your help!