Rails:4.0.0 Ruby:1.9.3
我在我的Rails应用程序中使用jQuery的animate()
方法。
我无法让它发挥作用。
我已经在jquery-ui-rails阅读了文档并按照那里提到的步骤进行了操作,即
gem 'jquery-ui-rails'
//= require jquery.ui.all
文件application.js
醇>
然而我收到Sprockets::FileNotFound
错误。
Showing /Users/anil20787/workspace/railsdir/depot/app/views/layouts/application.html.erb where line #9 raised:
couldn't find file 'jquery.ui.all'
(in /Users/anil20787/workspace/railsdir/depot/app/assets/javascripts/application.js:14)
的Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
我也查找了this post类似于我的问题,但它指的是文档,我已经遵循了它的步骤。不确定我在哪里弄错了。
感谢任何帮助。感谢
答案 0 :(得分:1)
根据this,包含的顺序很重要。你可以发布你的包含文件吗?
将//= require jquery.ui.all
放在//= require jquery
之后,这样看起来就像这样
//= require jquery
//= require jquery.ui.all
//= require jquery_ujs
//= require underscore
//= require backbone
//= require svitla_test
//= require_tree .
答案 1 :(得分:1)
重新启动我的Rails服务器为我做了。
答案 2 :(得分:1)
如果有人还在努力解决这个问题,我添加了gem 'rails-asset-jqueryui'
然后运行bundle install
,之后重启服务器...然后找到该文件,当然你还需要添加
//= require jquery.ui.all
文件中的 application.js
和
*= require jquery.ui.all
文件中的 applications.css