问题描述
我想实现这个http://www.eyecon.ro/colorpicker/#about 或 Active Admin 表单中的任何其他颜色选择器.
I want to implement this http://www.eyecon.ro/colorpicker/#about or any other color picker in one of the Active Admin form.
感谢您的帮助.
谢谢,GS
推荐答案
最快捷的方法是使用 input_html
选项将一个类添加到您的输入中.
The quickest way to get that working is simply add a class to your input using the input_html
options.
f.input :color, input_html: { class: 'colorpicker' }
然后在active_admin.js.coffee
中,添加将.colorpicker
输入框变成颜色选择器的代码.
And then in active_admin.js.coffee
, add in the code to turn .colorpicker
input fields into color pickers.
如果你打算制作很多它们,或者为它们添加选项,那么制作一个 自定义 Formtastic 输入,用于添加这些类并合并颜色选择器库可以选择的选项.
If you are going to be making a lot of them, or adding options to them, it might be worth it to make a custom Formtastic input that adds those classes and merges the options that can get picked up by the colorpicker library.
这篇关于如何在 Rails Active Admin 中添加颜色选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!