title: Rails: Dynamic select menu
body: <p>I'm following the tutorial of railscast #88 Dynamic select menus. I got an error in jquery part of it. I'm not a familiar in jquery I just follow his tutorial, I already searched the error.</p>
  
  <p>Error on console log</p>
  
  <pre><code>Uncaught Error: Syntax error, unrecognized expression: $serviceprovider_service_id :selected
  </code></pre>
  
  <p>_form.html.erb</p>
  
  <pre><code>&lt;%= form_for(@serviceprovider, html: { :multipart =&gt; true }, class: 'form-horizontal') do |f| %&gt;
  
        &lt;div class="form-group"&gt;
              &lt;label class="client-login-label"&gt;Service&lt;/label&gt;
              &lt;%= f.collection_select(:service_id, Service.all, :id, :service, prompt: 'Choose Service') %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
              &lt;label class="client-login-label"&gt;Category&lt;/label&gt;
              &lt;%= f.grouped_collection_select(:category_id, Service.order(:service), :categories, :service, :id, :name, prompt: 'Choose Category') %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;%= f.submit("Register", class: 'btn btn-lg btn-success client-signin-btn') %&gt;
        &lt;/div&gt;
      &lt;% end %&gt;
  </code></pre>
  
  <p>serviceprovider.js.coffee</p>
  
  <pre><code>jQuery -&gt;
      categories = $('#serviceprovider_category_id').html()
      $('#serviceprovider_service_id').change -&gt;
          service = $('#serviceprovider_service_id :selected').text()
          options = $(categories).filter("optgroup[label='#{service}']").html()
          if options
              $('#serviceprovider_category_id').html(options)
          else
              $('#serviceprovider_category_id').empty()
  </code></pre>
  
  <p>What's wrong with this. even I created a custom js file not a coffeescript it had a the same error.</p>