Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <%= semantic_form_for [:admin, @game], builder: ActiveAdmin::FormBuilder do |f| %>
  2. <%= f.semantic_errors :state %>
  3. <%= f.inputs do %>
  4. <%= f.input :categorization_id, label: 'Provider', as: :select,
  5. collection: Provider.all.map { |provider| ["#{provider.name}", provider.id] },
  6. input_html: { class: (:provider_select), 'data-url': category_select_path(provider: 4) } %>
  7. <%= f.input :categorization_id, label: 'Category',input_html: { class: ('category_dropdown') }, as: :select,
  8. collection: Category.all.map { |category| ["#{category.name}", category.id]}%>
  9. ...
  10.  
  11. <% end %>
  12. <%= f.actions %>
  13. <% end %>
  14.  
  15. controller do
  16. def ajax_call
  17. @provider = Provider.find(params[:provider])
  18. @categories = @provider.categories
  19. respond_to do |format|
  20. format.json { render json: @categories }
  21. end
  22. end
  23. end
  24.  
  25. $(document).on('ready page:load', function () {
  26.  
  27. $('.select.input.optional').last().addClass('hidden_row');
  28.  
  29. $('#game_categorization_id').change(function () {
  30. var id_value = this.value;
  31. $('.hidden_row').removeClass('hidden_row');
  32. $.ajax({
  33. type: 'GET',
  34. url: '/admin/games/category_select'
  35. // data: id_value
  36. })
  37. });
  38.  
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement