[英]rails 3 js code error
I have this code in my process_form.js.erb
file: 我的process_form.js.erb
文件中包含以下代码:
$('#write_offs_table > tbody').append('<tr class="list-line-<%= cycle('even', 'odd') %>" id="<%= @write_off.id %>">
<td class="name"><%= @write_off.date %></td>
<td><%= @write_off.user.name %></td>
<td><%= @write_off.status %></td>
</tr>');
it doesn't execute and chrome shows me an error: 它没有执行,chrome向我显示了一个错误:
Uncaught SyntaxError: Unexpected token ILLEGAL Uncaught SyntaxError:意外的令牌非法
Try this: 尝试这个:
$('#write_offs_table > tbody').append('<tr class=list-line-<%= cycle("even", "odd") %> id="<%= @write_off.id %>">\
<td class="name"><%= @write_off.date %></td>\
<td><%= @write_off.user.name %></td>\
<td><%= @write_off.status %></td>\
</tr>');
I used the \\
character to tell javascript that it continues on a new line. 我用\\
字符告诉javascript,它在新行中继续。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.