gem jquery-ui-rails couldn't find file 'jquery.ui.all' (

假装没事ソ 提交于 2019-12-19 06:00:51

问题


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 startup
couldn'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

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