简体   繁体   中英

Uncaught ReferenceError in jquery code compiled from coffeescript

I have the following jquery code (compiled from coffee script).

(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:

$ ->
  $.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.

Am I missing something (very basic) here?

Thanks!!

There is a tab indenting $.each and spaces elsewhere. Indentation is not correct. Use an editor with coffeescript support.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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