Mam kilka różnych przycisków, które wywołują tę samą funkcję i chciałbym, aby były zawijane w instrukcji switcha, zamiast używać kilku innych, jeśli warunki. Każda pomoc będzie świetna !!!Przełącznik case case w skrypcie do kawy
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?
To nie nadaje się do instrukcji switch mimo to (hasClass vs is). – user2864740