jquery - 找不到 'jquery-ui' Rails 3.2

标签 jquery ruby-on-rails ruby jquery-ui gemfile

为了解决这个问题,我到处找了找。我已经在我的 gemfile 中将 jquery-rails gem 降级为 2.3.0。但是当我在 application.js 中包含 jquery-ui 时,我仍然会收到 Sprokets::FileNotFound 错误。

couldn't find file 'jquery-ui'
  (in /home/richard/projects/pickaxe/mini-projects/depot-app/app/assets/javascripts/application.js:14)

这是我的 application.js 文件:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require_tree .

我很想知道为什么这不起作用......

最佳答案

如果您使用的是 jquery-ui-rails gem ,您需要使用 require jquery.ui.all 而不是 require jquery-ui。如果您不想使用 gem,请确保您的 app/assets/javascripts 文件夹中有一个 jquery-ui.js 文件。

更新

从版本 5.0.0 开始,使用 require jquery.ui

关于jquery - 找不到 'jquery-ui' Rails 3.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16996569/

相关文章:

javascript - 内容更改而不刷新时无法显示正在加载的 GIF 图片

ruby-on-rails - 如何减少ruby中数组的维数

ruby-on-rails - 如果 text_field_tag 中存在则显示值

ruby-on-rails - 事件管理员。始终在索引表上方显示顶级过滤器

Ruby:打印一些东西 x 次

使用线程时,ruby 内存使用量永远增长

javascript - 搜索onkeyup效率太低了吗?

jquery - 在html中找到最后一个事件元素

javascript - 在动画期间拒绝 jQuery 事件

Ruby 并发/异步处理(简单用例)