title: Data attributes in jQuery/Coffee script
body: <p>I have the following form code:</p>
  
  <pre><code> &lt;input data-color="orange" id="vote_color_id_2" name="color" type="radio" value="2" /&gt;Orange
   &lt;input data-color="blue" id="vote_color_id_3" name="color" type="radio" value="3" /&gt;Blue
   &lt;input data-color="green" id="vote_color_id_4" name="color" type="radio" value="4" /&gt;Green
  </code></pre>
  
  <p>I'm using Coffee script in rails and right now I'm just trying to alert the value of the data attribute <code>data-color</code>.</p>
  
  <p>This is my coffee script</p>
  
  <pre><code>jQuery -&gt;
      $("input[name='color']").change -&gt;
          color = this.data()
          alert color.color
  </code></pre>
  
  <p>The compiled jQuery looks like this:</p>
  
  <pre><code>(function() {
  
    jQuery(function() {
      return $("input[name='color']").change(function() {
        var color;
        color = this.data();
        return alert(color.color);
      });
    });
  
  }).call(this);
  </code></pre>
  
  <p>But I keep getting this error?</p>
  
  <pre><code>Uncaught TypeError: Object #&lt;HTMLInputElement&gt; has no method 'data'
  </code></pre>