我有一个 Rails 3.1 应用程序
在我的 gemfile 中:
gem 'jquery-rails', '>= 1.0.12'
在我的 asset/application.js 中,我有:
//= require jquery
//= require jquery_ujs
//= require_tree .
在我的 application.html 布局中,我包含了这些行
<%= javascript_include_tag "application" %>
<%= javascript_include_tag "jquery.min" %>
我使用的是 jQuery v1.6.2。
问题是,当我尝试访问任何页面时,我不断在控制台中收到这些错误:
Uncaught TypeError: Object function (selector,context){return new jQuery.prototype.init(selector,context);} has no method 'ajaxPrefilter' (:3000/assets/jquery_ujs.js?body=1:290)
Uncaught TypeError: Cannot read property 'setOffset' of undefined (:3000/assets/jquery-ui-1.8.18.custom.min.js?body=1:37)
Uncaught TypeError: Object function (a,b){return new jQuery.prototype.init(a,b)} has no method 'ajaxPrefilter' (application.js:12)
什么是 ajaxPrefilter,如何修复这些错误?
我尝试通过在 application.js 之前加载 jquery.min.js 来重新排序 javascript,但没有成功,而且我不确定如何检查 js 文件本身中的这些错误。
最佳答案
试试这个:
<%= javascript_include_tag "application" %>
<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" %>
<%= javascript_include_tag "http://code.jquery.com/ui/1.8.19/jquery-ui.min.js" %>
关于ruby-on-rails - Rails + jQuery ajaxPrefilter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10289235/