Trip
Trip

Reputation: 27114

How is this not a function in coffeescript?

Seems relatively straight forward :

_.each words, (val, key) -> $(".word_choice")[key].html val

Returns :

$(".word_choice")[key].html is not a function
[Break On This Error]   

return $(".word_choice")[key].html(val);

Can't figure this out. I'm using this reference :

http://autotelicum.github.com/Smooth-CoffeeScript/literate/underscore.html#each

Upvotes: 0

Views: 193

Answers (1)

Ry-
Ry-

Reputation: 224857

When accessing an element by index in a jQuery object, you get back a plain HTML element, not another jQuery object. Use .eq instead:

_.each words, (val, key) -> $(".word_choice").eq(key).html val

Upvotes: 6

Related Questions