Skip to content

Instantly share code, notes, and snippets.

@melhotiby
Last active August 29, 2015 14:14
Show Gist options
  • Save melhotiby/c66c41b6d9f4a1d2e65f to your computer and use it in GitHub Desktop.
Save melhotiby/c66c41b6d9f4a1d2e65f to your computer and use it in GitHub Desktop.
Dynamically reloading a select tag in rails
jQuery ($) ->
$('html').on 'change', '[data-reload]', (e) ->
e.preventDefault()
window.location = "#{$(this).data('url')}&#{$(this).data('params')}=#{$(this).val()}"
= select_tag :facility, options_for_select(['apples', 'oranges'], params[:facid]), data: { reload: true, url: spaces_path(q: params[:q]), params: 'facid' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment