1

Hi guys I'm working on this application using activeadmin. I've come to a point where I would like to add in some ajax based functions. I have the basic form set up using teh activeadmin resource and it generates a very pretty form.

I would like to while the user is entering the details on the form - run a ajax call which would retrieve some html based on the values being entered and populate it on the page.

More likely I would like a way to add custom javascript to the page. Whats the best way to do this - I'm facing issues with returning html without the entire activeadmin layout coming with it.

2 Answers 2

5

You can use the /config/initializers/active_admin.rb

You can add javascript resources like this:

config.register_javascript 'my_functions.js'
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, was having trouble how to figure out how to do this for ChartKick, was about to write a bunch of custom code, when I stumbled on this answer that turned it into just two lines: config.register_javascript "//www.google.com/jsapi" config.register_javascript "chartkick"
2

I use to put code directly to /app/assets/javascripts/active_admin.js

You can also include script in /config/initializers/active_admin.rb

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.