【问题标题】:Ruby on Rails in Cloud9 doesn't recognize jQuery/javascriptCloud9 中的 Ruby on Rails 无法识别 jQuery/javascript
【发布时间】:2023-04-08 01:02:01
【问题描述】:

我不知道为什么在 Cloud 9 框架中使用 Ruby on Rails 不识别 javascript 应用程序。 我通过 Udemy 参加了 Ruby on Rails 课程,这里是正确的 repo file 来自 Udemy 老师,当我将此代码复制到 Cloud 9 框架中时。在此文件中:/app/assets/javascripts/application.js 有这样的代码块:

var hide_spinner = function(){
  $('#spinner').hide();
}

并且在“$”符号内显示以下错误:$ is not defined; please fix or add /* global $ */。 javascripts文件夹中其他以.js结尾的文件也是如此。

我已经安装了所有的 gem 并且在 application.js 中:

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

对不起我的英语:)
请帮忙!

谢谢! ;)

【问题讨论】:

标签: javascript jquery ruby-on-rails cloud9-ide cloud9


【解决方案1】:

简单地添加这个:

/* global $ */

到脚本的顶部

$ is not defined; please fix or add /* global $ */ 将不再出现!

希望这有帮助,它对我有用!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-30
    • 2011-02-13
    相关资源
    最近更新 更多