Cambiar declaración de caso en script de café
Tengo algunos botones diferentes que llaman a la misma función y me gustaría incluirlos en una declaración de cambio en lugar de usar un montón de otras condiciones. ¡Cualquier ayuda sería genial!
events:
"click .red, .blue, #black, #yellow" : "openOverlay"
openOverlay: (e) ->
e.preventDefault()
e.stopPropagation()
target = $(e.currentTarget)
# the view should be opened
view =
if target.hasClass 'red' then new App.RedView
else if target.hasClass 'blue' then new App.BlueView
else if target.is '#black' then new App.BlackView
else
null
# Open the view
App.router.overlays.add view: view if view?