In JavaScript, when there isn't a `break` or `return` statement inside a `switch` case, the next case will be executed as well. That wasn't a problem here because CoffeeScript automatically inserts a `return` statement in this specific situation. However, since we don't want to return the result of the `hide()` operation, it might be easy to accidentally remove the `return` statement, causing the code to break. I've added a test for the scenario where neither `break` nor `return` statements are present, so we don't run into this error.
14 lines
497 B
CoffeeScript
14 lines
497 B
CoffeeScript
App.PollsAdmin =
|
|
|
|
initialize: ->
|
|
$("select[class='js-poll-shifts']").on
|
|
change: ->
|
|
switch ($(this).val())
|
|
when "vote_collection"
|
|
$("select[class='js-shift-vote-collection-dates']").show()
|
|
$("select[class='js-shift-recount-scrutiny-dates']").hide()
|
|
break
|
|
when "recount_scrutiny"
|
|
$("select[class='js-shift-recount-scrutiny-dates']").show()
|
|
$("select[class='js-shift-vote-collection-dates']").hide()
|