Skip to content

Instantly share code, notes, and snippets.

@jschwindt
Last active September 9, 2016 19:27
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 jschwindt/cefcc3705bc28cddb78b2588ab9f40cb to your computer and use it in GitHub Desktop.
Save jschwindt/cefcc3705bc28cddb78b2588ab9f40cb to your computer and use it in GitHub Desktop.
Actualización de combo de modelos cuando cambia la marca
jQuery ($) ->
$('#car_brand_id').change ->
$.getJSON "/brands/#{ $(this).val() }/models.json", (data) ->
items = [ '<option value=""> </option>' ]
$.each data, (key, val) ->
items.push("<option value='#{ val.id }'>#{val.name}</option>")
$('#car_model_id').html(items.join(''))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment