1

I'm building a custom action for rails admin that includes a custom view. I want to include a local copy of sparkline.js but I can't figure out a way to do this.

I tried to add the sparkline.js to the /vendor/assets/javascripts/actions/action_name directory but it is not loaded by rails admin

Is there any other way to get this file loaded

6
  • i think this thread should help: groups.google.com/forum/#!topic/rails_admin/KgUl3gF5kTg Commented Jun 27, 2013 at 20:17
  • @phoet mhh I had this solution in mind but the problem is that my changes to custom/ui.js would be overwritten by the users own changes. Antoher way would be to tell the user he should require the file in his custom/ui.js but thats not the best way I think :\ Commented Jun 28, 2013 at 14:18
  • the user? what does the user have to do with this? Commented Jun 28, 2013 at 16:57
  • The user who uses the plugin... Commented Jul 1, 2013 at 13:54
  • which plugin? you did not mention any plugin Commented Jul 1, 2013 at 13:55

1 Answer 1

4

I did this by putting the external library into the app/assets/javascripts/rails_admin/custom directory and adding a 'require' statement to the rails_admin ui.js file.

i.e.

// in app/assets/javascripts/rails_admin/custom/ui.js
//= require ./sparkline.js

You can do this with coffeescript too:

# in app/assets/javascripts/rails_admin/custom/ui.js.coffee
#= require ./sparkline.js
Sign up to request clarification or add additional context in comments.

1 Comment

what do i do for jquery? I need to execute things after jquery loads...!

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.