【发布时间】:2013-02-23 04:04:00
【问题描述】:
我正在尝试在手风琴中预先打开一个 div。我在相应的控制器中设置了一个实例变量@expanded_section。我正在尝试在 jQuery-UI 手风琴的 active 参数中使用该值,就像在 assets/javascripts 文件夹中的咖啡脚本文件上使用 erb 一样
$( ".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%>,
如果我对@expanded_section 进行to_i 调用,它会呈现active:0。
但是当我将@expanded_section 的值从控制器打印到控制台时,它会打印正确的预期值。
请帮忙。
【问题讨论】:
标签: jquery ruby-on-rails coffeescript erb