简体   繁体   English

Ruby on Rails 3.1 TypeError:'word'在.js.coffee文件中未定义

[英]Ruby on Rails 3.1 TypeError: 'word' is undefined in .js.coffee file

I wrote some JQuery code in an .js.coffee file and I get the following error: TypeError: 'word' is undefined. 我在.js.coffee文件中写了一些JQuery代码,我收到以下错误:TypeError:'word'未定义。

I am new with Rails 3.1 so I am not sure what this error message means. 我是Rails 3.1的新手,所以我不确定这个错误信息是什么意思。

Here is a snippet of the code int the .js.coffee file: 这是.js.coffee文件中的代码片段:

 $(document).ready(function(){ 
$("#project_name").focus(function(){
    changeBorder("project_name");
});
$("#project_name").blur(function(){
    resetBorder("project_name");
});
...
});

 function changeBorder(formName){
$("#" + formName).css({border: '1px solid #168DD8', background: '#f2f2f2'});
 }

 function resetBorder(formName){
$("#" + formName).css({border: '1px solid #999999', background: '#ffffff'});
 }

Appreciate any help. 感谢任何帮助。

why are you writing javascript in your .js.coffee file? 你为什么要在.js.coffee文件中编写javascript? If you want to use Javascript, rename file extension to .js 如果要使用Javascript,请将文件扩展名重命名为.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM