0

我想实现视觉标记,作为基于Railscasts插曲:http://railscasts.com/episodes/258-token-fields-revised麻烦与选择和引导

出于某种原因,所选择的库无法找到(请参阅从JavaScript控制台下面的错误)。我也有点担心有所有引导程序错误。

的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() 

从编辑/表格视图

<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:从JavaScript控制台

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 

错误消息:

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. 

编辑

附加信息:我只是在渲染页面的源代码发现两个链接到选定的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> 

当我点击第一个,我看到一个JavaScript库。第二个链接只是返回一个空白页面。

EDIT 2

我设法通过移动去除引导错误需要的jQuery后引导,但仍然得到选择的错误。

//= require jquery 
//= require jquery_ujs 
//= require chosen-jquery 
//= require bootstrap 
//= require_tree . 

**编辑3 **

相关问题:chosen-rails error chosen is not a function

回答

1

解决

一番搜索和修改代码后,我在配置更改的静态资产指令/ environments/development.rb

config.serve_static_assets = false 
+0

PS如果有人能解释发生在这里的事情,我会接受它作为答案。 – ardochhigh