I'm trying to implement visual tags, as based on the Railscasts episode: http://railscasts.com/episodes/258-token-fields-revised
For some reason the chosen library cannot be found (see error below from the javascript console). I'm also a bit concerned there are all those bootstrap errors.
application.js
//= require bootstrap //= require jquery //= require chosen-jquery //= require jquery_ujs //= require_tree . application.css
*= require_self *= require chosen *= require_tree . sentences.js.coffee
jQuery -> $('#sentence_tag_list').chosen() from edit/form view
<div class="sentence"> <%= f.label :tag_list, "Tags (separated by commas)" %><br /> <%= f.text_field :tag_list, label: false, :input_html => {multiple: true} %> </div> Gemfile:
group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' gem "bootstrap-sass", ">= 2.3.0.0" gem 'jquery-rails' gem 'font_awesome_rails' gem 'chosen-rails' # for tag formatting end Error messages from javascript console:
Uncaught TypeError: undefined is not a function bootstrap-transition.js:30 Uncaught TypeError: Cannot read property 'fn' of undefined bootstrap-affix.js:72 Uncaught TypeError: Cannot read property 'fn' of undefined bootstrap-alert.js:72 Uncaught TypeError: Cannot read property 'fn' of undefined bootstrap-button.js:68 Uncaught TypeError: Cannot read property 'fn' of undefined bootstrap-carousel.js:159 Uncaught TypeError: Cannot read property 'fn' of undefined bootstrap-collapse.js:127 Uncaught TypeError: Cannot read property 'fn' of undefined bootstrap-dropdown.js:138 Uncaught TypeError: Cannot read property 'fn' of undefined bootstrap-modal.js:199 Uncaught TypeError: Cannot read property 'fn' of undefined bootstrap-scrollspy.js:125 Uncaught TypeError: Cannot read property 'fn' of undefined bootstrap-tab.js:114 Uncaught TypeError: Cannot read property 'fn' of undefined bootstrap-tooltip.js:327 Uncaught TypeError: Cannot read property 'fn' of undefined bootstrap-popover.js:38 Uncaught TypeError: Cannot read property 'fn' of undefined bootstrap-typeahead.js:295 Uncaught TypeError: Object [object Object] has no method 'chosen' sentences.js?body=1:3 event.returnValue is deprecated. Please use the standard event.preventDefault() instead. EDIT
Additional info: I just noticed in the rendered page source two links to the chosen libray.
<script src="/assets/chosen.jquery.js?body=1" type="text/javascript"></script> <script src="/assets/chosen-jquery.js?body=1" type="text/javascript"></script> When I click on the first I see a javascript library. The second link just returns a blank page.
EDIT 2
I managed to remove the bootstrap errors by moving require bootstrap after jquery, but a still getting the chosen error.
//= require jquery //= require jquery_ujs //= require chosen-jquery //= require bootstrap //= require_tree . ** EDIT 3**
Related question: chosen-rails error chosen is not a function