我想在我的 Rails 3 应用程序中使用 jQuery 而不是 Prototype。
Rails 3 的“官方”方法是什么?
最佳答案
首先,您需要安装 gem,将这一行添加到 Gemfile 中:
gem 'jquery-rails', '>= 0.2.6'
(并运行捆绑安装
)
然后,您需要转到 public/javascript 文件夹,并将rails.js 文件替换为:http://github.com/rails/jquery-ujs 中的文件。 .
正确的做法是:
rails generate jquery:install
或者如果您想包含 jQuery UI:
rails generate jquery:install --ui
来自 Github 页面:
This will remove the Prototype.js library from Rails, add latest jQuery library and fetch the adapter. Be sure to choose to overwrite the "rails.js" file.
关于jquery - 如何在 Rails 3 应用程序中使用 jQuery 而不是 Prototype?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5053280/