title: Can't make Stimulus JS data-action in collection_select Rails 6
body: <p>I'm new to Stimulus JS. I'm a little stuck trying to make a simple event fire using <code>collection_select</code> in a form (created with rails g scaffold).</p>
  <p>Here's my <code>dropdown-controller.js</code> (stimulus) file:</p>
  <pre><code>import { Controller } from &quot;stimulus&quot;
  
  export default class extends Controller {
    static targets = [&quot;target&quot;];
  
    handleChange() {
      console.log('works!')
    }
  }
  </code></pre>
  <p>Here's my <code>_forms.html.erb</code> file:</p>
  <pre><code>&lt;%= form_with(model: stock_order, local: true) do |form| %&gt;
    ...
  
    &lt;section data-controller=&quot;dropdown&quot;&gt;
      &lt;div class=&quot;field&quot;&gt;
        &lt;%= form.label :company_id %&gt;
        &lt;%= form.collection_select :company_id, Company.all, :id, :name, data: {action: &quot;change-&gt;dropdown#handleChange&quot;} %&gt;
      &lt;/div&gt;
    &lt;/section&gt;
  
    &lt;div class=&quot;actions&quot;&gt;
      &lt;%= form.submit %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  <p>I've tried many things:</p>
  <p><code>&lt;%= form.collection_select :company_id, Company.all, :id, :name, data: {action: &quot;change-&gt;dropdown#handleChange&quot;} %&gt;</code></p>
  <p><code>&lt;%= form.collection_select :company_id, Company.all, :id, :name, {data: {action: &quot;change-&gt;dropdown#handleChange&quot;}} %&gt;</code></p>
  <p><code>&lt;%= form.collection_select :company_id, Company.all, :id, :name, data: {action: &quot;dropdown#handleChange&quot;} %&gt;</code>
  ...etc</p>
  <p>I can only get to fire the <code>console.log('works!)</code> if I use html select tags instead of rails' <code>collection_select</code>. The event fires if I create a test button or if I use <code>form.check_box</code> instead.</p>
  <p>Any ideas? Sorry if it's a stupid question, I'm out of ideas.</p>
  <p>Thanks!</p>