我想使用activeadmin_addons gem将active2 js与activeadmin一起应用

时间:2016-03-01 12:59:51

标签: jquery ruby-on-rails ruby-on-rails-4 activeadmin select2

I want to apply select2 js with activeadmin using activeadmin_addons gem on has_may through associations but when I apply all the things which are mentioned in gem it looks like select2 js not loading

I have apply all the changes for like what we need to include in js and css files 

when I try to add new record by add more record it gives error like this
 **$(...).select2 is not a function**

主动管理表格: **

form do |f|
    f.semantic_errors *f.object.errors.keys
    f.inputs 'Collection details' do
      f.input :title
      f.input :description
    end
    #f.input :wires, :input_html => { :class => "chosen-input" } # other model with has_many relation ship
    f.inputs 'Wires' do
      f.has_many :collection_wires, allow_destroy: true, new_record: true, heading: false do |collection_wire_f|
        collection_wire_f.input :wire
      end
    end
    f.actions
  end

**

active_admin.js.coffee

#= require active_admin/base
#= require activeadmin_addons/all

当我查看页面源代码时,它会显示在代码使用之前加载的select2以及在jquery和jquery之后加载的ujs

我想在我们处于新页面或编辑页面时,应该使用select2 js来搜索数据。

请建议任何解决方案

2 个答案:

答案 0 :(得分:0)

我发现解决方案存在js的路径问题,当我在开发模式下预编译资产时,它对我不起作用。

答案 1 :(得分:0)

我认为这是在这里修复的:https://github.com/platanus/activeadmin_addons/issues/65 并包含在this release