(->
jQuery ->
globalThis = @
$('#emailTypes').change ->
globalThis.toggleEmailOptions()
toggleEmailOptions = ->
$('.emailTypeOptions').fadeOut 'fast', ->
for emailType in $('#emailTypes').val()
$("##{emailType}Options").fadeIn()
).call this
That’s my .coffee file. However, the toggleEmailOptions function isn’t in scope of the jQuery ready. How can I make it in scope?
I think you don’t need to wrap because coffeescript already do it, here’s how I would rewrite your code: