2中使用javascript而不使用coffeescript

2中使用javascript而不使用coffeescript

本文介绍了在rails 3.2中使用javascript而不使用coffeescript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Rails 3.2,它设置为coffeescript。我知道Coffeescript是一个真棒语言,它不是太难学习,但我开始包装我的头围绕Javascript和jQuery。所以我的问题是这是:有一个简单的方法来设置rails 3.2到使用Javascript,而不是?
目前,我的jQuery是在我的视图中的< script>< / script> 标签(timeline / index.html.erb)。我想把它移动到一个.js文件。我尝试将timeline.js.coffee的名称更改为timeline.js并将jQuery放入其中,但我收到未捕获的SyntaxError:意外的令牌ILLEGAL

I'm using Rails 3.2, It's set up for coffeescript. I know Coffeescript is an awesome language and it's not too hard to learn, but i'm JUST starting to wrap my head around Javascript and jQuery. So my question is this: Is there an easy way to set rails 3.2 up to use Javascript instead?At the moment, my jQuery is in <script></script> tags in my view (timeline/index.html.erb). I'd like to move it into a .js file. I tried changing the name of my timeline.js.coffee to just timeline.js and putting the jQuery in there, but I get Uncaught SyntaxError: Unexpected token ILLEGAL.

除了learn coffeescript的明显回答,我应该怎么办?

What should I do besides the obvious answer of "learn coffeescript"?

推荐答案

我在正确的轨道上。要在rails 3.2中切换到javascript,你只需要删除 .coffee 扩展。但是,您还需要确保使用 // 作为注释,而不是

I was on the right track. To switch to javascript in rails 3.2 you only need to remove the .coffee extension. However, you also need to make sure you use // for comments instead of #

//# Place all the behaviors and hooks related to the matching controller here.
//# All this logic will automatically be available in application.js.
//# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

这篇关于在rails 3.2中使用javascript而不使用coffeescript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 06:44