Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExecJS::ProgramError: SyntaxError: Reserved word "function"

In our rails rfq.js.coffee, we only have a simple js code:

$(function() {   $('#need_report').change(function(){     if ($(this).val() == true) {       $('#report_language').hide();     }  // end if   });  // end change() });  // end ready(function) 

However this code causes an error saying that function() in first line is a reserved word. Since the first line is basically a jquery $(document).ready(function () {}), we have no clue why this error shows up. Any thoughts about it? Thanks so much.

like image 644
user938363 Avatar asked Jan 25 '12 22:01

user938363


1 Answers

You can't use standard JS like that in a Coffeescript file. Either rename the file to rfq.js, or convert it to coffeescript:

$ ->   $('#need_report').change ->     if $(this).val()       $('#report_language').hide() 
like image 86
Dylan Markow Avatar answered Oct 06 '22 01:10

Dylan Markow