[英]Uncaught ReferenceError in jquery code compiled from coffeescript
I have the following jquery code (compiled from coffee script). 我有以下jquery代码(从coffee脚本编译)。
(function() {
$(function() {
return $.get('/proteins', function(proteins) {});
});
$.each(proteins, function(index, protein) {
return $('#proteins').append($("<li>").text(protein.name));
});
}).call(this);
The coffeescript that generated this code looks like this: 生成此代码的coffeescript如下所示:
$ ->
$.get '/proteins', (proteins) ->
$.each proteins, (index, protein) ->
$('#proteins').append $("<li>").text protein.name
I keep getting a "Uncaught ReferenceError: proteins is not defined" at line 6 of my generated code. 我在生成的代码的第6行中不断收到“ Uncaught ReferenceError:蛋白未定义”。
Am I missing something (very basic) here? 我在这里错过什么(非常基本)吗?
Thanks!! 谢谢!!
There is a tab indenting $.each and spaces elsewhere. 有一个制表符,用于缩进$ .each和其他位置的空格。 Indentation is not correct. 缩进不正确。 Use an editor with coffeescript support. 使用具有coffeescript支持的编辑器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.