Skip to content

Instantly share code, notes, and snippets.

Created November 9, 2013 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/7389380 to your computer and use it in GitHub Desktop.
Save anonymous/7389380 to your computer and use it in GitHub Desktop.
Gist created from Brackets
jQuery ->
$('#counselor_supervisor_employee_position_id').hide()
position = $('#counselor_supervisor_employee_position_id').html()
$('#counselor_supervisor_employee_department_id').change ->
department = $('#counselor_supervisor_employee_department_id :selected').text()
escaped_department = department.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1')
options = $(position).filter("optgroup[label='#{escaped_department}']").html()
if options
$('#counselor_supervisor_employee_position_id').html(options)
$('#counselor_supervisor_employee_position_id').show()
else
$('#counselor_supervisor_employee_position_id').empty()
$('#counselor_supervisor_employee_position_id').hide()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment