-
-
Save kivanio/9400aa50c749e7e52593 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveAdmin.register CityNeighbourhood do | |
member_action :change_neighbourhoods, :method => :get do | |
@neighbourhoods = City.find_by_id(params[:city_id]).try(:neighbourhoods) | |
render :text => view_context.options_from_collection_for_select(@neighbourhoods, :id, :name) | |
end | |
#... | |
form do |f| | |
f.input :city, input_html: { | |
onchange: remote_get("change_neighbourhoods", 'city_id', :neighbourhood_id) | |
} | |
f.input :neighbourhood | |
end | |
#... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveAdmin::ViewsHelper | |
def remote_get(path, member,target_tag_id) | |
"$.get('#{path}/?#{member}=' + $('##{member}').val(), | |
function(data) {$('##{target_tag_id}').html(data);} | |
);" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment