I want to hide an option in my form unless a specific option is selected but my coffee script doesn’t seem to work. It looks like:
jQuery ->
$('.input.boolean.optional').hide()
selected = $('#stand_type :selected').text()
value = "Microphone"
$('#stand_type').change ->
$('.input.boolean.optional').show() if selected is value
This code compiles correctly. Yes I am aware of the IDs and class selectors, they are different in the code as I’m using simple_form which only gives a div a class this is why when hiding it I’m using a class not an ID. The html for my form looks like.
The logic in your script is wrong. Your checking for the value before its updated so it will always be empty your script should look like this: