When I use active_admin/select2 in my active_admin.js file, has_many form duplicates enter image description here , any ideas what`s going on with javascript? When I comment active_admin/select2 line, duplication is gone, but selector does not working anymore.
app/admin/user.rb
f.inputs do
f.has_many :team_members, allow_destroy: true do |a|
a.input :first_name
a.input :last_name
a.input :email
a.input :groups, as: :select, collection: a.object.groups_for_select, multiple: true, include_hidden: false, input_html: { class: 'groups' }
a.input :manager
end
end
javascript/application.js
//= require select2
vendor/active_admin.js
//= require jquery.js
//= require active_admin/base
//= require active_admin/select2
I found solution here answer , I actually rename my active_admin.js to active_admin.js.erb and added next code.
<%
require_asset "active_admin/select2.js"
require_asset "active_admin/base"
%>
Now it's look like this and working perfectly for me. Duplication is gone.
//= require active_admin/base
//= require active_admin/select2
<%
require_asset "active_admin/select2.js"
require_asset "active_admin/base"
%>
# Other js code...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.