I have the following form code:
<input data-color="orange" id="vote_color_id_2" name="color" type="radio" value="2" />Orange <input data-color="blue" id="vote_color_id_3" name="color" type="radio" value="3" />Blue <input data-color="green" id="vote_color_id_4" name="color" type="radio" value="4" />Green
I am using Coffee script in rails, and now I'm just trying to warn the value of the data-color data attribute.
This is my coffee script.
jQuery -> $("input[name='color']").change -> color = this.data() alert color.color
Compiled jQuery looks like this:
(function() { jQuery(function() { return $("input[name='color']").change(function() { var color; color = this.data(); return alert(color.color); }); }); }).call(this);
But do I keep getting this error?
Uncaught TypeError: Object
jquery coffeescript
Slick23
source share