Rails Admin: add javascript library to custom action

早过忘川 提交于 2020-01-15 15:31:02

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/17349458/rails-admin-add-javascript-library-to-custom-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!