select2-rails gem is not working on Rails4

前端 未结 4 578
一个人的身影
一个人的身影 2021-01-02 17:55

I have tried given documentation for the select2-rails gem, but my browser console still throws an error.

Uncaught TypeError: $(...).select2 is not a

4条回答
  •  日久生厌
    2021-01-02 18:50

    I never encountered this issue while using rails 4.1.5 & select2-rails 3.5.9.3. However, after upgrading rails to 4.2.4, I get the same exact error described in this question:

    Uncaught TypeError: $(...).select2 is not a function

    I was able to resolve the error by removing the "select2-rails" gem from my Gemfile and replacing it with:

    source 'https://rails-assets.org' do
      gem 'rails-assets-select2', '~> 4.0.0'
    end
    

提交回复
热议问题