javascript - Twitter bootstrap jquery plugins not compiled for production

試著忘記壹切 提交于 2019-12-04 03:21:59

Found it!

It wasn't a problem of bootstrap, but rather with properly precompiling jQuery. As well as there is no need for including the javascript files for individual plugins. They are already included in the main twitter/bootstrap.

Problem was solved by re-arranging the javascripts files as follows:

application.js

//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap

Gemfile

group :assets do
  gem 'sass-rails',   '~> 3.1.5'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
  gem "twitter-bootstrap-rails"
end

gem 'jquery-rails', '>= 1.0.12'

Precompling the assets and worked!

In your /vendor/assets/javascripts place a file vendor_js.js with the following content:

//= require_tree .

Now in your /app/assets/javascripts/application.js include a line

//= require vendor_js

You can customize the vendor_js.js to only include specific vendor plugins, e.g. by using //= require bootstrap-dropdown to include only the bootstrap dropdowns within the vendor javascripts directory.

UPDATE TO REFLECT COMMENTS

Since you put the bootstrap JS files into vendor/javascripts manually, please remove all bootstrap-related requires from your application.js and paste them into vendor_js.js as noted above. Make sure you get the path right (in case you put the files in a subdirectory). Also make sure to include each file separately and place the inclusion of tooltip before popover, since popover depends on tooltip to be loaded first.

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