找不到文件“jquery-ui”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17830313/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Couldn't find file 'jquery-ui'
提问by Sam
I am getting the following error even if I have jquery-ui in my application.js file
即使我的 application.js 文件中有 jquery-ui,我也会收到以下错误
couldn't find file 'jquery-ui' (in /home/jeff/work/projects/a/media/app/assets/javascripts/application.js:14)
找不到文件“jquery-ui”(在 /home/jeff/work/projects/a/media/app/assets/javascripts/application.js:14 中)
application.js
应用程序.js
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require jquery.validate.min
Can anybody help me?
有谁能够帮助我?
回答by Debadatt
Use specific version of gem "jquery-rails", "~> 2.3.0"
as later version of gem has deleted the ui part.
使用特定版本,gem "jquery-rails", "~> 2.3.0"
因为更高版本的 gem 删除了 ui 部分。
or
或者
you can use gem "jquery-ui-rails"
for jquery-ui
. For more information please visit the git repository
你可以gem "jquery-ui-rails"
用于jquery-ui
. 有关更多信息,请访问git 存储库
To require all jQuery UI modules, add the following to your application.js:
要要求所有 jQuery UI 模块,请将以下内容添加到您的 application.js:
for version 5.0 and more it has been changed. Please follow the link
对于 5.0 及更高版本,它已更改。请按照链接
application.js:
应用程序.js:
//= require jquery-ui
application.css:
应用程序.css:
/*
*= require jquery-ui
*/
For lesser version than 5.0 we need to write below format
对于低于 5.0 的版本,我们需要编写以下格式
application.js:
应用程序.js:
//= require jquery.ui.all
Also add the jQuery UI CSS to your application.css:
还要将 jQuery UI CSS 添加到您的 application.css 中:
application.css:
应用程序.css:
/*
*= require jquery.ui.all
*/
Hope this could help you
希望这可以帮助你
回答by rails_id
I think you are using new version (your version > 2.3.0) of jquery-rails.
我认为您正在使用 jquery-rails 的新版本(您的版本 > 2.3.0)。
jQuery UI has been removed from jquery-rails gem,
jQuery UI 已从 jquery-rails gem 中删除,
≤ jquery-rails v2.3.0
still have jQuery UI≥ jquery-rails v3.0.0
jQuery UI removed
≤ jquery-rails v2.3.0
仍然有 jQuery UI≥ jquery-rails v3.0.0
jQuery UI 被移除
Take a look this commit.
看看这个提交。
If you are using ≥ jquery-rails v3.0.0
or latest version of jquery-rails
如果您正在使用 ≥ jquery-rails v3.0.0
或最新版本的 jquery-rails
You should use jquery-ui-rails
gem for using jquery UI in rails, https://github.com/joliss/jquery-ui-rails.
您应该使用jquery-ui-rails
gem 在 rails 中使用 jquery UI,https://github.com/joliss/jquery-ui-rails。
In your Gemfile, add:
在您的 Gemfile 中,添加:
gem 'jquery-ui-rails'
gem 'jquery-ui-rails'
and run bundle install
并运行 bundle install
v2.3.0 < your version ≤ v4.2.1
And put this into
application.js
//= require jquery.ui.all
then put this into
application.css
*= require jquery.ui.all
≥ jquery-ui-rails v5.0.0 or latest version
And put this into
application.js
//= require jquery-ui
then put this into
application.css
*= require jquery-ui
or to use specific modules read this
v2.3.0 < 您的版本 ≤ v4.2.1
并将其放入
application.js
//= require jquery.ui.all
然后把它放进去
application.css
*= require jquery.ui.all
≥ jquery-ui-rails v5.0.0 或最新版本
并将其放入
application.js
//= require jquery-ui
然后把它放进去
application.css
*= require jquery-ui
或使用特定模块阅读此
Don't forget restart your server.
不要忘记重新启动服务器。
If you are using ≤ jquery-rails v2.3.0
如果您正在使用 ≤ jquery-rails v2.3.0
see my answer here https://stackoverflow.com/a/16996710/1297435for use gem 'jquery-rails', "~> 2.3.0"
在此处查看我的答案https://stackoverflow.com/a/16996710/1297435以供使用gem 'jquery-rails', "~> 2.3.0"
回答by Joe Susnick
The rails 4 answer:
铁轨 4 答案:
add to gemfile.rb:
添加到 gemfile.rb:
gem 'jquery-ui-rails'
add to application.js:
添加到 application.js:
//= require jquery
//= require jquery-ui
//= require jquery_ujs
to add a specific module:
添加特定模块:
//= require jquery
//= require jquery-ui/yourmodulename
//= require jquery_ujs
I'm not sure if restarting your server is explicitly required but it never hurts anything.
我不确定是否明确需要重新启动服务器,但它永远不会伤害任何东西。
回答by doz87
I know its a noob mistake but I found this very frustrating and always forget to restart my app after I have installed something new.
我知道这是一个菜鸟错误,但我发现这非常令人沮丧,并且在我安装了新的东西后总是忘记重新启动我的应用程序。
Make sure to restart your rails server after you have followed the instructions above and it should work perfectly.
按照上述说明操作后,请确保重新启动 rails 服务器,它应该可以正常工作。
回答by ronnygeo
Kind of a noob mistake, but if it helps anyone..
有点菜鸟的错误,但如果它帮助任何人..
I added jQuery-ui.js in my assets and then added the gem. Then deleted the js from assets, but my IDE also deleted the same files from the gem.
我在我的资产中添加了 jQuery-ui.js,然后添加了 gem。然后从资产中删除了 js,但我的 IDE 也从 gem 中删除了相同的文件。
To resolve, first remove the gem and then run,
要解决,首先删除 gem 然后运行,
bundle clean --force
and then
进而
bundle install
回答by rii
It could just be a matter of restarting WEBrick or any other server you might be using so it picks up the new assets. For WEBrick just go to your terminal window where your server is running and CTRL-C
to terminate the process, after that just restart it again using rails s
or whatever the command to start your server is.
这可能只是重新启动 WEBrick 或您可能正在使用的任何其他服务器的问题,以便它获取新资产。对于 WEBrick,只需转到运行服务器的终端窗口并CTRL-C
终止进程,然后只需使用rails s
或启动服务器的任何命令重新启动它。