Skip to content

Instantly share code, notes, and snippets.

@wolfieorama
Created April 26, 2016 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolfieorama/a91517e7281a7d1ee36a04345892d7b5 to your computer and use it in GitHub Desktop.
Save wolfieorama/a91517e7281a7d1ee36a04345892d7b5 to your computer and use it in GitHub Desktop.
$(document).ready ->
cities = $('#person_city_id').html()
# console.log(cities)
$('#person_country_id').change ->
country = $('#person_country_id :selected').text()
options = $(cities).filter("optgroup[label='#{country}']").html()
# console.log(options)
if options
$('#person_city_id').html(options)
else
$('#person_city_id').empty()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment