Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%= semantic_form_for [:admin, @game], builder: ActiveAdmin::FormBuilder do |f| %>
- <%= f.semantic_errors :state %>
- <%= f.inputs do %>
- <%= f.input :categorization_id, label: 'Provider', as: :select,
- collection: Provider.all.map { |provider| ["#{provider.name}", provider.id] },
- input_html: { class: (:provider_select), 'data-url': category_select_path(provider: 4) } %>
- <%= f.input :categorization_id, label: 'Category',input_html: { class: ('category_dropdown') }, as: :select,
- collection: Category.all.map { |category| ["#{category.name}", category.id]}%>
- ...
- <% end %>
- <%= f.actions %>
- <% end %>
- controller do
- def ajax_call
- @provider = Provider.find(params[:provider])
- @categories = @provider.categories
- respond_to do |format|
- format.json { render json: @categories }
- end
- end
- end
- $(document).on('ready page:load', function () {
- $('.select.input.optional').last().addClass('hidden_row');
- $('#game_categorization_id').change(function () {
- var id_value = this.value;
- $('.hidden_row').removeClass('hidden_row');
- $.ajax({
- type: 'GET',
- url: '/admin/games/category_select'
- // data: id_value
- })
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement