Formal, ActiveAdmin adding javascript
How to add javascript action with formastic and activeadmin:
I look like this:
f.input :role, :as => :select, :collection => User.display_roles.each_with_index.map{|x,i| [x,User.roles[i]]} , :include_blank => nil
f.input :organization, :input_html => { :disabled => false }
I would like to add a javascript where the organization will change after changing the role. How to do it??
+3
source to share
2 answers
Following the idea of not having intrusive js, you can also put this in a js file (example :) utils.js
:
$(function(){
$('#your_model_role').change(function() {
what you want to happen goes here
});
});
And then in /config/initializers/active_admin.rb
put the lineconfig.register_javascript 'utils.js'
+2
source to share