为什么jQuery无法在我的Rails 3.2.3应用程序中加载? [英] Why is jQuery not loading in my Rails 3.2.3 app?

查看:73
本文介绍了为什么jQuery无法在我的Rails 3.2.3应用程序中加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到昨天,jQuery仍在我的Rails应用程序中正常加载.我正在安装调试器/ruby​​-debug gem.如您所知,Rails 3中的调试器gem存在问题,并且我没有成功获取依赖项,因此我从Gemfile中删除了gem.从那时起,加载我的网站时jQuery不再加载.这些是我在控制台中看到的消息:

Up until yesterday jQuery was loading just fine in my Rails app. I was playing around with getting the debugger/ruby-debug gem installed. As you are probably aware there are issues with the debugger gem in Rails 3 and I was unsuccessful in getting the dependancies installe so I removed the gems from my Gemfile. Since then when loading my site jQuery is not loading. These are the messages I see in console:

assets/jquery_ujs.js?body=1:377Uncaught ReferenceError: jQuery is not defined
bootstrap-transition.js:24Uncaught TypeError: undefined is not a function
bootstrap.js:3Uncaught ReferenceError: jQuery is not defined
welcome:210Uncaught ReferenceError: $ is not defined

这是我的application.js文件:

And here is my application.js file:

//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require_tree .

如果我像这样将jQuery显式加载到layouts/application.html.erb中,它将起作用:

If I load jQuery explicitly in layouts/application.html.erb, like so, it works:

<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" %>
<%= javascript_include_tag "application" %>

关于如何解决此问题并重新加载jQuery的任何想法?在.rvm/gems/ruby​​-1.9.3-p125/gems/jquery-rails-2.0.2/vendor/assets/javascripts中查看,我可以看到jquery.js和jquery.min.js仍然存在.

Any thoughts on what I can do to resolve this and get jQuery loading again? Looking in .rvm/gems/ruby-1.9.3-p125/gems/jquery-rails-2.0.2/vendor/assets/javascripts I can see jquery.js and jquery.min.js are still there.

推荐答案

感谢@Djj.重新排序我的application.js树似乎已经解决了这个问题.这是我修改过的树:

Thanks @Djj. Re-ordering my application.js tree seems to have resolved the issue. Here is my revised tree:

//= require jquery_ujs
//= require jquery
//= require twitter/bootstrap
//= require jquery.placeholder
//= require_tree .

这篇关于为什么jQuery无法在我的Rails 3.2.3应用程序中加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆