Reputation: 6657
I'm using Rails 4, trying to get Chosen to work but it does not render, instead the standard multi select menu displays. I have done everything in the railscast here: http://railscasts.com/episodes/258-token-fields-revised?autoplay=true
but Chosen does not work. Any advice or alterations? The files are below:
Gemfile:
gem 'chosen-rails', '1.0.1'
gem 'compass-rails', github: 'Compass/compass-rails'
_field.html.erb :
<%= f.label :category_ids, "Restaurant Categories" %>
<%= f.collection_select :category_ids, Category.all, :id, :name, {}, {multiple: true} %>
application.js :
//= require jquery
//= require chosen-jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree .
application.css:
*
*= require_self
*= require chosen
*= require_tree .
*/
users.js.coffee:
jQuery ->
$('#category_ids').chosen()
Upvotes: 0
Views: 760
Reputation: 4
I've just faced the same issue. Solved it this way:
Added jquery-turbolinks gem via:
gem 'jquery-turbolinks'
Updated application.js as stated in jquery-turbolinks gem:
//= require jquery //= require jquery.turbolinks //= require jquery_ujs // // ... your other scripts here ... // //= require turbolinks
I hope you find this useful.
Upvotes: 0
Reputation: 4831
One thing I would try is to load jquery-ujs
before chosen-rails
in your application.js
So your application.js
would look like
//= require jquery
//= require jquery_ujs
//= require chosen-jquery
//= require bootstrap
//= require turbolinks
//= require_tree .
Hopefully this helps fix your problem
Upvotes: 1