问题
I'm trying to add jquery ui datepicker to my application with help of jquery-ui-rails gem. I've checked Railscast I seem to do everything right, but i get an error upon application startupcouldn't find file 'jquery.ui.all'
Gemfile(end of it, tried to include gem in the assets group but no luck):
gem 'backbone-on-rails'
gem "jquery-ui-rails"
application.js
//= require jquery
//= require jquery_ujs
//= require underscore
//= require backbone
//= require svitla_test
//= require_tree ../templates
//= require_tree ./models
//= require_tree ./collections
//= require_tree ./views
//= require_tree ./routers
//= require_tree .
//= require jquery.ui.all
application.css
*= require jquery.ui.all
*= require_self
*= require_tree .
回答1:
Put //= require jquery.ui.all
right after //= require jquery
so it will look like this
//= require jquery
//= require jquery.ui.all
//= require jquery_ujs
//= require underscore
//= require backbone
//= require svitla_test
//= require_tree ../templates
//= require_tree ./models
//= require_tree ./collections
//= require_tree ./views
//= require_tree ./routers
//= require_tree .
note that the order of which these lines are written is the order which these files are loaded.. So if you call a jquery-ui
function before it knows what jquery-ui
is, most likely you need to change the order a bit..
It is usually good to put infrastructure files before your own files to avoid these kind of problems
回答2:
At version 5.0 it has been changed. You can read more about it here.
version 5.0:
application.js:
//= require jquery-ui
application.css:
/*
*= require jquery-ui
*/
version 4.x (I'm sure about 4.2.0 and 4.2.1):
application.js:
//= require jquery.ui.all
application.css:
/*
*= require jquery.ui.all
*/
来源:https://stackoverflow.com/questions/15874265/gem-jquery-ui-rails-couldnt-find-file-jquery-ui-all