The do
notation does compile to an IIFE, yous still need the actual handler function:
dropdown = $('<select />') .on 'change', do(myView = @) -> (e) -> myVieW.prop = @.value
# or wrap the whole handler assignment:
do(myView = @) ->
dropdown = $('<select />') .on 'change', (e) -> myVieW.prop = @.value
Or you just use lexical this
:
dropdown = $('<select />') .on 'change', (e) => @.prop = e.target.value
dropdown = $('<select />') .on 'change', (e) => @.prop = dropdown.val()