让select2与活动管理员一起工作 [英] Getting select2 to work with active admin
问题描述
我正在使用具有Active Admin的应用程序,需要从选择输入中选择多个值,所以我添加了Select2 gem,它添加了所有相关的JS和CSS都没有问题,但是由于某些原因,选择框似乎可以略微改变外观,但不改变Select2的外观,经过检查,JS看起来好像没有添加所有正确的类……有什么想法吗?
I am working with an app with Active Admin and needed to select multiple values from a select input, I have added the Select2 gem which adds all the relevant the JS and CSS with no issues but for some reason the select boxes seem to change their appearance slightly but not to the ful Select2 appearance, upon inspection the JS doesn't look like its added all the correct classes...... any ideas?
这是我的代码:
active_admin.css.scss
active_admin.css.scss
//= require select2
@import "active_admin/mixins";
@import "active_admin/base";
active_admin.js
active_admin.js
//= require select2
//= require active_admin/base
$(".select2able").select2({
placeholder: "Select a Partner"
});
activeadmin表单
activeadmin form
f.input :sponsors, as: :select, collection: Sponsor.all, input_html: {class: 'select2able'}
推荐答案
问题已解决,使用选择的js代替select2,效果和select2一样好,但在活动管理员中没有问题。
Problem solved, use chosen js instead of select2, works equally as well as select2 but without the issues in active admin.
https://github.com/gregbell/ active_admin / issues / 2267#issuecomment-19197807
这篇关于让select2与活动管理员一起工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!