我正在尝试在手风琴中预先打开一个 div。我@expanded_section在相应的控制器中设置一个实例变量。我正在尝试在 jQuery-UI 手风琴的参数中使用该值,就像在文件夹active中的咖啡脚本文件上使用 erbassets/javascripts
$( ".sections" ).accordion({
active: <%=@expanded_section%>,
header: "h4",
collapsible: true,
heightStyle: "content" }).sortable({
axis: "y",
handle: "h4",
update: ->
$.post($(this).data('update'), $(this).sortable('serialize'))
})
但我收到以下错误:
Error: Parse error on line 60: Unexpected ','
(在/home/steve/dev/rails/Survey/app/assets/javascripts/surveyys.js.coffee.erb)
line 60是active: <%=@expanded_section%>,
如果我to_i调用@expanded_section它会呈现active:0.
但是当我@expanded_section从控制器将值打印到控制台时,它会打印正确的预期值。
请帮忙。