TypeError: $(…).selectize is not a function

做~自己de王妃 提交于 2019-12-05 06:00:33

I think you have a jQuery dependency issue caused by the jQuery-rails gem. Try this:

1) Comment out this line in your Gemfile

gem 'coffee-rails', '~> 4.0.1'
#gem 'jquery-rails', '~> 2.3.0'
gem 'turbolinks', '~> 1.1.1'

2) Run bundle install

3) Download this version of jQuery and put in in your vendor/assets/javascript folder.

EDIT

To migrate to the non-gem version place these files in the following paths:

  • vendor/assets/stylesheets/selectize.css
  • vendor/assets/javascript/selectize.min.js
  • vendor/assets/javascript/sifter.js
  • vendor/assets/javascript/microplugin.js

For me, the issue was that my application code was being included before selectize.js. Adding //= require selectize to app/assets/javascripts/application.js before //= require_tree . fixed it.

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require selectize
//= require_tree .

I had resolved same issue by removing jQuery include, that was included twice. There's note about that in the comments, but it's collapsed and I figured that out myself. Posting this as answer for people to notice it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!